Beispiel #1
0
        private void Awake()
        {
            _eventBinder  = new SceneEventBinder();
            _sceneChanges = new Queue <IEnumerator>();

            var metas = Resources.LoadAll <SceneMeta>("");

            _sceneMetas = new Dictionary <string, SceneMeta>(metas.Length);

            SceneMeta firstSceneMeta = null;

            foreach (var meta in metas)
            {
                _sceneMetas.Add(meta.Scene, meta);
                if (meta.Scene == TopScene)
                {
                    firstSceneMeta = meta;
                }
            }

            if (firstSceneMeta != null)
            {
                ChangeActiveScene(firstSceneMeta.name);
            }
        }
Beispiel #2
0
        private IEnumerator SceneChangeCoroutine(SceneMeta targetScene)
        {
            var loadingScene = targetScene.LoadingScene;

            if (StackCount > 2 && loadingScene.Enabled)
            {
                yield return(LoadSceneCoroutine(loadingScene.Scene.Name));

                _eventBinder.Dispatch(loadingScene.Scene.Name, SceneEventType.Shown);
                yield return(new WaitForSeconds(loadingScene.Duration));

                if (!targetScene.IsAdditive)
                {
                    yield return(UnloadSceneCoroutine(PreviousScene));
                }
                yield return(LoadSceneCoroutine(targetScene.Scene));

                yield return(new WaitForSeconds(loadingScene.Duration));

                yield return(UnloadSceneCoroutine(loadingScene.Scene.Name));
            }
            else
            {
                yield return(LoadSceneCoroutine(targetScene.Scene));

                if (StackCount > 2 && !targetScene.IsAdditive)
                {
                    yield return(UnloadSceneCoroutine(PreviousScene));
                }
            }
            ChangeActiveScene(TopScene);
        }