Beispiel #1
0
    private void ShowScene(SceneType sceneType, params object[] sceneArgs)
    {
        if (scenes.ContainsKey(sceneType))
        {
            currentSceneBase = scenes[sceneType];
            currentSceneBase.OnShowing();
            currentSceneBase.OnResetArgs(sceneArgs);
            currentSceneBase.gameObject.SetActive(true);
            currentSceneBase.OnShowed();
        }
        else
        {
            if (parentObj == null)
            {
                parentObj = UIRoot;
            }
            string name = sceneType.ToString();

            GameObject scene = new GameObject(name);
            UnityHelper.AddUIChildNodeToParentNode(parentObj, scene.transform);
            SceneBase currentScene = scene.AddComponent(Type.GetType(name)) as SceneBase;

            currentSceneBase = currentScene;
            CurrentSceneType = sceneType;

            currentSceneBase.OnInit(sceneArgs);
            currentSceneBase.OnShowing();
            SetLayer(currentSceneBase.gameObject, LayerType.Scene);
            currentSceneBase.OnShowed();
            scenes.Add(sceneType, currentSceneBase);
            switchRecoders.Add(new SwitchRecorder(sceneType, sceneArgs));
        }
    }
Beispiel #2
0
    /// <summary>
    /// 打开指定场景
    /// </summary>
    /// <param name="sceneType"></param>
    /// <param name="sceneArgs">场景参数</param>
    private void ShowScene(SceneType sceneType, params object[] sceneArgs)
    {
        if (scenes.ContainsKey(sceneType))
        {
            current = scenes[sceneType];
            current.OnShowing();
            current.OnResetArgs(sceneArgs);
            current.gameObject.SetActive(true);
            current.OnShowed();
        }
        else
        {
            if (sceneType == SceneType.None)
            {
                current = null;
                return;
            }

            GameObject go    = new GameObject(sceneType.ToString());
            Type       mType = Type.GetType(sceneType.ToString());
            current = go.AddComponent(mType) as SceneBase;
            current.OnInit(sceneArgs);
            scenes.Add(current.type, current);
            current.OnShowing();
            LayerMgr.GetInstance.SetLayer(current.gameObject, LayerType.Scene);
            go.transform.localPosition(Vector3.zero).localRotation(Quaternion.identity).localScale(1);
            current.OnShowed();
        }
    }
Beispiel #3
0
 /// <summary>
 /// Show assigned scene
 /// </summary>
 private void ShowScene(SceneType sceneType, params object[] sceneArgs)
 {
     if(scenes.ContainsKey(sceneType)){
         current = scenes[sceneType];
         current.OnShowing();
         current.OnResetArgs(sceneArgs);
         NGUITools.SetActive(current.gameObject, true);
         current.OnShowed();
     }
     else{
         GameObject go = new GameObject(sceneType.ToString());
         //sceneType.tostring = classname for current scene
         current = UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(go, "Assets/Script/Core/View/SceneMgr.cs (120,14)", sceneType.ToString()) as SceneBase;
         current.OnInit(sceneArgs);
         scenes.Add(current.type, current);
         current.OnShowing();
         LayerMgr.GetInstance().SetLayer(current.gameObject, LayerType.Scene);
         go.transform.localScale = Vector3.one;
         go.transform.localRotation = Quaternion.identity;
         current.OnShowed();
     }
 }