Beispiel #1
0
        private IEnumerator LoadSceneInNextFrame(SceneChangeEvent e)
        {
            yield return(new WaitForEndOfFrame());

            AddParams(e);
            var requestedScene = e.Scene.ToString();

            this.Log("Scene change requested: " + requestedScene, LogLevel.Info);

            if ((SceneName)Enum.Parse(typeof(SceneName), requestedScene) == SceneName.Back)
            {
                if (_lastScene != SceneName.Back)
                {
                    if (_lastScene == SceneName.Initialization)
                    {
                        throw new Exception("Can't load Initialization scene. Game should be initialized once. \n " +
                                            "Invoke scene loading with 'Back' parameter cause this problem.");
                    }
                    SceneManager.LoadSceneAsync(_lastScene.ToString());
                    _lastScene = SceneName.Back;
                }
                yield break;
            }

            string currentScene = SceneManager.GetActiveScene().name;

            if (currentScene != requestedScene)
            {
                _lastScene = (SceneName)Enum.Parse(typeof(SceneName), currentScene);

                if (requestedScene == "Initialization")
                {
                    throw new Exception("Can't load Initialization scene. Game should be initialized once.");
                }
                SceneManager.LoadSceneAsync(requestedScene, e.LoadMode);
            }
        }
Beispiel #2
0
        private void OnSceneChangeEvent(object sender, EventArgs arg)
        {
            SceneChangeEvent e = arg as SceneChangeEvent;

            _sceneChangesQueue.Enqueue(e);
        }
Beispiel #3
0
 private void AddParams(SceneChangeEvent e) => _params.AddOrModify(e.ParamKey, e.ParamValue);