Example #1
0
    public IEnumerator PreloadSceneOperation(SceneType sceneType, LoadSceneMode loadSceneMode = LoadSceneMode.Single)
    {
        print("PreloadSceneOperation sceneType = " + sceneType.ToString() + ", index = " + (int)sceneType);
        sceneLoader = SceneManager.LoadSceneAsync(sceneType.ToString(), loadSceneMode);
        sceneLoader.allowSceneActivation = false;

        while (!sceneLoader.isDone)
        {
            yield return(null);

            if (sceneLoader.progress >= 0.9f)
            {
                print("onPreloadComplete");
                isPreloadCompleted = true;
                if (onPreloadComplete != null)
                {
                    onPreloadComplete();
                }
                break;
            }
            else
            {
                if (onPreloadRateChanged != null)
                {
                    onPreloadRateChanged(sceneLoader.progress);
                }
            }
        }
    }
Example #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();
        }
    }
        public bool MoveScene(SceneType type)
        {
            // Debug.Log("Move->" + type.ToString());
            if (type == CurrentScene)
            {
                Debug.Log($"移動先が一緒 : {type.ToString()}");
                return(false);
            }

            if (_IsFadeing)
            {
                Debug.Log($"フェード中");
                return(false);
            }


            Debug.Log("Move->" + type.ToString() + ":" + SceneNameList[(int)(type)]);
            UnityEngine.SceneManagement.SceneManager.LoadScene(SceneNameList[(int)(type)]);

            CurrentScene = type;
            // NextScene = type;
            if (CurrentScene == SceneType.Game)
            {
                //! kaetai
                MainGameManager.Instance.StartGame();
            }

            return(true);
        }
Example #4
0
    /// <summary>
    /// 加载场景
    /// </summary>
    /// <param name="type"></param>
    public void LoadScene(SceneType type)
    {
        if (m_CurrentSceneType == type && m_CurrentSceneType == SceneType.Main)
        {
            return;
        }
        m_CurrentSceneType = type;



        //if (SceneMgr.Instance.CurrentSceneBundle != null)
        //{
        //    SceneMgr.Instance.CurrentSceneBundle.Unload(true);
        //    SceneMgr.Instance.CurrentSceneBundle = null;
        //}
        AudioEffectManager.Instance.StopAllAudio();
        UIViewManager.Instance.ClearWindows();
        //AssetBundleManager.Instance.UnloadAssetBundle();
        Resources.UnloadUnusedAssets();

        if (SceneDic.ContainsKey(type) && SceneDic[type] != null)
        {
            SceneManager.LoadScene("Scene_" + type.ToString());
            return;
        }

#if UNITY_EDITOR
        SceneManager.LoadScene("Scene_" + type.ToString());
#else
        SceneManager.LoadScene(string.Format("Scene_Loading_{0}", ConstDefine.GAME_NAME));
#endif
    }
    private void Load(SceneType p_type)
    {
        Debug.Log("Scene Controller: State to - " + p_type.ToString());

        m_currentScene = p_type;

        if (m_animator != null)
        {
            m_animator.Play(p_type.ToString());
        }
    }
Example #6
0
    IEnumerator transitionAsync(SceneType name, float duration)
    {
        FadeMgr.Instance.countText.enabled = true;
        FadeMgr.Instance.animeObj.SetActive(true);

        yield return(new WaitWhile(() => m_isFade));

        m_async = SceneManager.LoadSceneAsync(name.ToString(), LoadSceneMode.Additive);
        // 読み込みが終わっても表示しない
        m_async.allowSceneActivation = false;

        // 読み込み終わるまで待機(0.9までしか増えない)
        while (m_async.progress < 0.9f)
        {
            FadeMgr.Instance.SetCounter(m_async.progress);
            yield return(0);
        }

        // 強制的に100%に
        FadeMgr.Instance.SetCounter(1);

        // 90%->100%のTwennが終わるまで待機
        yield return(new WaitWhile(() => FadeMgr.Instance.Counter != 100));

        // Load完了から少し待つ
        yield return(new WaitForSeconds(1));

        // 読み込みが完了しているSceneを表示
        m_async.allowSceneActivation = true;

        yield return(null);

        UnLoadScene(m_currentScene);
        m_currentScene = name;

        if (duration != 0)
        {
            FadeMgr.Instance.FadeIn(duration, () =>
            {
                FadeMgr.Instance.countText.enabled = false;
                FadeMgr.Instance.animeObj.SetActive(false);
                FadeMgr.Instance.SetCounter(0);
                MyDebug.Log(name.ToString() + "_Scene : LoadComplete!!");
            });
        }
        else
        {
            FadeMgr.Instance.countText.enabled = false;
            FadeMgr.Instance.animeObj.SetActive(false);
            FadeMgr.Instance.SetCounter(0);
            MyDebug.Log(name.ToString() + "_Scene : LoadComplete!!");
        }
    }
		public Task<bool> ChangeSceneAsync(SceneType sceneEnum)
		{
			this.tcs = new TaskCompletionSource<bool>();
			// 加载map
			this.loadMapOperation = SceneManager.LoadSceneAsync(sceneEnum.ToString());
			return this.tcs.Task;
		}
Example #8
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));
        }
    }
Example #9
0
    public void SwitchingScene(SceneType sceneType, params object[] sceneArgs)
    {
        if (currentSceneBase != null)
        {
            if (sceneType == currentSceneBase.type)
            {
                Debug.Log("试图切换场景至当前场景:" + sceneType.ToString());
                //HideCurrentScene();
                //ShowScene(sceneType, sceneArgs);
                return;
            }
        }

        if (sceneType == mainSceneType)//进入主场景,把切换场景记录清空
        {
            switchRecoders.Clear();
        }
        switchRecoders.Add(new SwitchRecorder(sceneType, sceneArgs));//切换记录

        HideCurrentScene();
        ShowScene(sceneType, sceneArgs);
        if (OnSwitchingSceneHandler != null)
        {
            OnSwitchingSceneHandler(sceneType);
        }
    }
Example #10
0
            /// <summary>
            /// 使用enum取得Scene的Type.
            /// </summary>
            /// <param name="type"></param>
            /// <returns></returns>
            public static Type GetSceneType(SceneType type)
            {
                return(Type.GetType(type.ToString()));

                #region old getSceneType

                //switch (type)
                //{
                //    case SceneType.InitScene:
                //        return typeof(InitScene);

                //    case SceneType.StartScene:
                //        return typeof(StartScene);

                //    case SceneType.CommonPlayScene:
                //        return typeof(CommonPlayScene);

                //    case SceneType.CommonPlayTimerScene:
                //        return typeof(CommonTimerPlayScene);

                //    default:
                //        Debug.LogError
                //            ("Try get a inexistence scene!! Go to Scripts/YsUIFrameWork/Common/Define to Modify GetSceneType( ) ");
                //        return null;
                //}

                #endregion
            }
Example #11
0
        public void GotoScene(SceneType type)
        {
            m_CurrentSceneType = type;
            string tmpSceneName = type.ToString();

            if (SceneMachine == null)
            {
                SceneMachine = SceneMachine.GetSingleton();
            }

            GameScene tmpScene = SceneMachine.GetState(tmpSceneName) as GameScene;

            if (tmpScene == null)
            {
                return;
            }
            GameScene tmpCurrentScene = SceneMachine.GetCurrentScene() as GameScene;

            if (tmpCurrentScene == tmpScene)
            {
                //两次跳转的场景相同,则返回;
                return;
            }
            SceneMachine.SetNextState(tmpScene.pStateName);
        }
 void Start()
 {
     score = GetComponent <Text>();
     if (destinationScene.ToString() == "Score")
     {
         score.text = ScoreController.currentScore.ToString();
     }
     else if (destinationScene.ToString() == "HighestScore")
     {
         score.text = ScoreController.highestScore.ToString();
     }
     else
     {
         score.text = ScoreController.highestScore.ToString();
     }
 }
Example #13
0
            public static string GetSceneName(SceneType type)
            {
                return(type.ToString());

                #region old getSceneName

                //switch (type)
                //{
                //    case SceneType.None:
                //        return null;

                //    case SceneType.InitScene:
                //        return "00_Init";

                //    case SceneType.StartScene:
                //        return "01_Start";

                //    case SceneType.CommonPlayScene:
                //        return "03_CommonPlay";

                //    case SceneType.CommonPlayTimerScene:
                //        return "04_CommonTimerPlay";

                //    default:
                //        return null;
                //}

                #endregion
            }
Example #14
0
    public void SwitchScene(SceneType sceneType , params object[] sceneArgs)
    {
        string name = sceneType.ToString();
        //GameObject scene = ResourceMgr.GetInstance().CreateGameObject("Game/UI/"+name, false);
        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;
        scene.transform.parent.localEulerAngles = Vector3.zero;
        scene.transform.localScale = Vector3.one;
        scene.transform.localPosition = Vector3.zero;
        LayerMgr.GetInstance().SetLayer(baseObj.gameObject, LayerType.Scene);
        if (name.Equals(mainSceneName))
        {//如果进入主场景,则清空记录
            switchRecorder.Clear();
        }

        switchRecorder.Add(new SwitchRecorder(sceneType, sceneArgs));
        if (curren != null)
        {
            GameObject.Destroy(curren);
        }
        curren = scene;
    }
Example #15
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;
    }
Example #16
0
    //切换场景
    public void SwitchScene(SceneType type)
    {
        //清楚数据
        ClearData();
        _currentScene = type;
        switch (type)
        {
        case SceneType.Init:
            LoadScene(SceneType.Init);
            break;

        case SceneType.Login:
            LoadScene(SceneType.Login);
            break;

        case SceneType.Loading:
            LoadScene(SceneType.Loading);
            break;

        case SceneType.Main:
            LoadSceneByLoading(SceneType.Main);
            break;

        case SceneType.Game:
            LoadSceneByLoading(SceneType.Game);
            break;

        default:
            Log.Debug("没有找到场景" + type.ToString());
            break;
        }
    }
Example #17
0
    /// <summary>
    /// 加载场景
    /// </summary>
    /// <param name="newState"></param>
    public void LoadScene(SceneType type)
    {
        if (m_CurrentSceneState != null)
        {
            m_CurrentSceneState.OnExit();
        }

        m_NextType = type;

        if (SceneDic.ContainsKey(type))
        {
            //if (SceneMgr.Instance.CurrentSceneBundle != null)
            //{
            //    SceneMgr.Instance.CurrentSceneBundle.Unload(true);
            //    SceneMgr.Instance.CurrentSceneBundle = null;
            //}
            AudioEffectManager.Instance.StopAllAudio();
            UIViewManager.Instance.ClearWindows();
            //AssetBundleManager.Instance.UnloadAssetBundle();
            Resources.UnloadUnusedAssets();
            SceneManager.LoadScene("Scene_" + type.ToString());
        }
        else
        {
            SceneManager.LoadScene("Scene_Loading");
        }
    }
Example #18
0
        IEnumerator LoadSceneProcess(SceneType sceneType)
        {
            UIManager.Fade(FadeType.Out);

            yield return(new WaitForSeconds(Properties.FadeOutDuration));

            SceneManager.LoadScene(sceneType.ToString());
        }
Example #19
0
 public static void UnLoad(SceneType sceneType)
 {
     if (SceneManager.sceneCount <= 1)
     {
         return;
     }
     SceneManager.UnloadScene(sceneType.ToString());
 }
Example #20
0
    IEnumerator OnChangeScene()
    {
        AndroidBackKeyManager.Instance.StackClear();

        if (isAsyncLoad)
        {
            // 非同期ロード
            //参照が切れているリソースを確実に開放するために、シーン切替時に空シーンを挟む
            AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("SceneEmpty");

            while (!asyncOperation.isDone)
            {
                yield return(new WaitForEndOfFrame());
            }

            yield return(new WaitForEndOfFrame());

            Resources.UnloadUnusedAssets();

            asyncOperation = SceneManager.LoadSceneAsync(changeSceneType.ToString());

            while (!asyncOperation.isDone)
            {
                yield return(new WaitForEndOfFrame());
            }
        }
        else
        {
            // 同期ロード(画面を動かすため何回か yield return null している)
            //参照が切れているリソースを確実に開放するために、シーン切替時に空シーンを挟む
            SceneManager.LoadScene("SceneEmpty");

            Resources.UnloadUnusedAssets();

            yield return(null);

            SceneManager.LoadScene(changeSceneType.ToString());
        }

        if (TutorialManager.IsExists)
        {
            TutorialFSM.Instance.SendFsmEvent("CHANGED_SCENE");
        }

        CommonFSM.Instance.SendFsmNextEvent();
    }
Example #21
0
    private IEnumerator loadScene()
    {
        AudioListener.pause = false; // reset mute state every time when switching to a new scene
        Time.timeScale      = 1;     // reset the time scale every time a new scene is loaded so the gameplay animations wont freeze
        screenTransition.SetTrigger("start");
        yield return(new WaitForSecondsRealtime(1f));

        SceneManager.LoadScene(destinationScene.ToString());
        yield return(false);
    }
Example #22
0
    private static IEnumerator LoadSceneAsync(SceneType scene)
    {
        yield return(null);

        loadingAsyncOperation = SceneManager.LoadSceneAsync(scene.ToString());

        while (!loadingAsyncOperation.isDone)
        {
            yield return(null);
        }
    }
Example #23
0
    public IEnumerator InitializeSceneCoroutine(SceneType type, string structureName = "")
    {
        switch (type)
        {
        case SceneType.Title:
            yield return(SceneManager.LoadSceneAsync(type.ToString()));

            yield return(new WaitForSeconds(1f));

            GameDataManager.Instance.SetCanvasActive(false);
            var titleCamera      = ObjectManager.Instance.LevelCamera;
            var titleLight       = ObjectManager.Instance.LevelLight;
            var titleEventSystem = ObjectManager.Instance.EventSystem;
            Instantiate(PrefabHolder.Instance.titleManager).Animate();
            break;

        case SceneType.LevelSelect:
            var levelSelectManager = ObjectManager.Instance.LevelSelectManager;
            var levelDisplay       = ObjectManager.Instance.LevelDisplay;
            break;

        case SceneType.Level:
            yield return(SceneManager.LoadSceneAsync(type.ToString()));

            yield return(new WaitForSeconds(1f));

            ObjectManager.Instance.GameStateManager.state = GameState.Wave;
            GameDataManager.Instance.InitializeForGameScene();
            var enemyManager    = ObjectManager.Instance.EnemyManager;
            var camera          = ObjectManager.Instance.LevelCamera;
            var light           = ObjectManager.Instance.LevelLight;
            var canvas          = ObjectManager.Instance.LevelCanvas;
            var inputManager    = ObjectManager.Instance.LevelInputManager;
            var eventSystem     = ObjectManager.Instance.EventSystem;
            var progressManager = ObjectManager.Instance.LevelProgressManager;
            var waveManager     = ObjectManager.Instance.WaveManager;
            waveManager.LoadStructure(structureName);
            waveManager.Initialize();
            break;
        }
    }
Example #24
0
    IEnumerator transition(SceneType name, float duration)
    {
        yield return(new WaitWhile(() => m_isFade));

        yield return(SceneManager.LoadSceneAsync(name.ToString(), LoadSceneMode.Additive));

        UnLoadScene(m_currentScene);
        m_currentScene = name;

        if (duration != 0)
        {
            FadeMgr.Instance.FadeIn(duration, () =>
            {
                Debug.Log(name.ToString() + "_Scene : LoadComplete!!");
            });
        }
        else
        {
            Debug.Log(name.ToString() + "_Scene : LoadComplete!!");
        }
    }
Example #25
0
 public void LoadSceneWhenFadingComplete(SceneType sceneType)
 {
     // 1. start Fading
     // 2. on fading complete, LoadScene
     StartFading
     (
         fadeType: SceneFadeType.FadeIn,
         onFadingComplete: () => {
         SceneManager.LoadScene(sceneType.ToString());
     }
     );
 }
Example #26
0
        private static SceneBase getSceneBaseByType(SceneType type, object arg = null)
        {
            switch (type)
            {
            case SceneType.City:
                return(CityScene.Create(arg));

            case SceneType.Login:
                return(LoginScene.Create(arg));
            }
            Debug.LogError("getSceneBaseByType is null " + type.ToString());
            return(null);
        }
Example #27
0
    public static void ChangeScene(SceneType sceneType)
    {
        string sceneName = "";

        if (_sceneNameDictionary.TryGetValue(sceneType, out sceneName))
        {
            SceneManager.LoadScene(sceneName);
        }
        else
        {
            Debug.Log($"Scene changing method - cannot get scene name of type [{sceneType.ToString()}]");
        }
    }
Example #28
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Debug.Log(type.ToString());
         //change scene
         if (type != SceneType.none)
         {
             player.SavePlayerPos();
             SceneManager.LoadScene(Scenes.SceneName(type));
         }
     }
 }
Example #29
0
 /// <summary>
 /// 取得登路场景的名称
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public string GetSceneStrBySceneType(SceneType type)
 {
     if (enumDic != null && enumDic.Count > 0)
     {
         string str = enumDic[type];
         return(str);
     }
     else
     {
         Debug.LogWarning("没有找到场景:" + type.ToString());
         return(SceneType.SceneLogin.ToString());//返回开始界面
     }
 }
Example #30
0
    private static void InitScene()
    {
        if (SceneCtrl_)
        {
            Destroy(SceneCtrl_);
        }

        SceneCtrl_ = new GameObject(SceneType_.ToString());
        SceneCtrl_.transform.parent = Instance.transform;
        switch (SceneType_)
        {
        case SceneType.Launcher:
            SceneCtrl_.AddComponent <Launcher>();
            break;

        case SceneType.Loading:
            UIManager.ShowPanel <LoadingPanel>();
            break;

        case SceneType.Login:
            // 重新初始化数据
            CameraManager.Instance.MainCamera.transform.localPosition    = Vector3.zero;
            CameraManager.Instance.MainCamera.transform.localEulerAngles = Vector3.zero;
            Animator animator = CameraManager.Instance.MainCamera.GetComponent <Animator>();
            if (animator != null)
            {
                Destroy(animator);
            }
            UIManager.ShowPanel <LoginPanel>();
            break;

        case SceneType.MainScene:
            UIManager.ShowPanel <UserStatusPanel>();
            break;

        case SceneType.BattleScene:
            SceneCtrl_.AddComponent <BattleSceneDisplayManager>();
            UIManager.ShowPanel <BattleSkillPanel>();
            UIManager.ShowPanel <BattleCameraControlPanel>();
            UIManager.ShowPanel <BattleMiniMapPanel>();
            UIManager.ShowPanel <BattleRetreatEntrance>();
            break;

        case SceneType.Deploy:
            SceneCtrl_.AddComponent <DeploySceneManager>();
            break;

        default:
            break;
        }
    }
Example #31
0
        public static Scene Create(SceneType sceneType)
        {
            switch (sceneType)
            {
            case SceneType.Menu:
                return(new MenuScene());

            case SceneType.Game:
                return(new GameScene());

            default:
                return(new Scene(sceneType.ToString()));
            }
        }
Example #32
0
	/// <summary>
	/// Switchs the scene.
	/// </summary>
	/// <param name="name">要创建的资源路径</param>
    /// <param name="objParams">可变参数</param>
	public void SwitchScene(SceneType sceneType , params object[] objParams)//GameObject
	{
		//GameObject obj = ResourceMsg.GetInstance ().CreateGameObject (name, cache);

		string name = sceneType.ToString ();
        GameObject go = new GameObject(name);
        SceneBase scene = go.AddComponent(Type.GetType(name)) as SceneBase;
        //scene.Init();
        scene.OnInit(objParams);

        if (parentObj == null)
        {
            //此处写法欠妥,还需要改进
            parentObj = GameObject.Find("UI Root").transform;
        }
        go.transform.SetParent(parentObj);
        go.transform.localEulerAngles = Vector3.zero;
        go.transform.localScale = Vector3.one;
        go.transform.localPosition = Vector3.zero;

        //如果是进入到主场景,清空记录
        if (name.Equals(mainScene))
        {
            switchRecorders.Clear();
        }

		switchRecorders.Add(new SwitchRecorder(sceneType, objParams));

		if (currentShow != null) 
		{
			GameObject.Destroy (currentShow);
		}
        currentShow = go;

        LayerMgr.GetInstance().SetLayer(go, LayerType.Scene);
	}
Example #33
0
		/// <summary>
		///		Creates a <see cref="SceneManager"/> instance based on scene type support.
		/// </summary>
		/// <remarks>
		///		Creates an instance of a <see cref="SceneManager"/> which supports the scene types
		///		identified in the parameter. If more than one type of SceneManager
		///		has been registered as handling that combination of scene types,
		///		in instance of the last one registered is returned.
		/// </remarks>
		/// <param name="sceneType"> A mask containing one or more <see cref="SceneType"/> flags.</param>
		/// <returns></returns>
		public SceneManager CreateSceneManager( SceneType sceneType )
		{
			var instanceName = ( new NameGenerator<SceneManager>() ).GetNextUniqueName( sceneType.ToString() );
			return this.sceneManagerEnumerator.CreateSceneManager( sceneType, instanceName );
		}
Example #34
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();
     }
 }
Example #35
0
    /// <summary>
    /// Siwtch Scene
    /// </summary>
    /// <param name="sceneType"></param>
    /// <param name="sceneArgs"></param>
    public void SwitchingScene(SceneType sceneType, params object[] sceneArgs)
    {
        if(current != null){
            if (sceneType == current.type){
                Debug.LogError ("try to switch scene tos current scene" + sceneType.ToString());
                return;
            }
        }

        //enter mainScene, clear switchRecorders
        if (sceneType == mainSceneType){
            switchRecorders.Clear ();
        }

        //switch Record
        switchRecorders.Add (new SwitchRecorder(sceneType, sceneArgs));

        HideCurrentScene();
        ShowScene(sceneType, sceneArgs);
        if (OnSwitchingSceneHandler != null){
            OnSwitchingSceneHandler(sceneType);
        }
    }