Ejemplo n.º 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));
        }
    }
Ejemplo n.º 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();
        }
    }
Ejemplo n.º 3
0
    public void SwitchScene(SceneType sceneType, params object[] sceneArgs)
    {
        string     name    = sceneType.ToString();
        GameObject scene   = new GameObject(name);
        SceneBase  baseObj = scene.AddComponent(Type.GetType(name)) as SceneBase;

        //baseObj.Init(sceneArgs);
        baseObj.OnInit(sceneArgs);
        if (parentObj != null)
        {
            parentObj = GameObject.Find("UI Root").transform;
        }
        scene.transform.parent = parentObj;


        LayerMgr.GetInstance().SetLayer(baseObj.gameObject, LayerType.Scene);

        scene.transform.localEulerAngles = Vector3.zero;
        scene.transform.localScale       = Vector3.one;
        scene.transform.localPosition    = Vector3.zero;
        if (name.Equals("SceneHome"))
        {
            switchRecorder.Clear();
        }

        switchRecorder.Add(new SwitchRecorder(sceneType, sceneArgs));
        if (current != null)
        {
            GameObject.Destroy(current);
        }

        current = scene;
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 切换Scene
    /// </summary>
    /// <param name="state">Scene</param>
    public void SceneSwitch(SceneState state)
    {
        parentObj = GameObject.Find("Canvas").transform;
        string     name  = state.ToString();
        GameObject scene = new GameObject(name);

        scene.transform.parent           = parentObj;
        scene.transform.localEulerAngles = Vector3.zero;
        scene.transform.localPosition    = Vector3.zero;
        scene.transform.localScale       = Vector3.one;
        SceneBase sb = scene.AddComponent(Type.GetType(name)) as SceneBase;

        sb.OnInit();

        if (pervious != null)
        {
            UnityEngine.Object.Destroy(pervious);
        }
        pervious = scene;
    }
Ejemplo n.º 5
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();
     }
 }