void Start()
        {
            CurrentSceneStateProperty.Where(css => css != null).Subscribe(css =>
            {
                if (IsCampaignRunning)
                {
                    CurrentCampaign.CurrentScene = css;
                }

                if (SceneManager != null && SceneManager.TransitionManager != null)
                {
                    SceneManager.NextScene.Value = css.SceneName;
                }
                else
                {
                    TransitionHelper.LoadScene(css.SceneName);
                }
            }).AddTo(this);

            IsCampaignRunningProperty.Subscribe(running => {
                if (running)
                {
                    CurrentCampaign.SessionStarted = DateTime.Now;
                    CurrentSceneState = CurrentCampaign.CurrentScene;
                }
                else
                {
                    CurrentSceneState = new MainMenuState();
                }
            }).AddTo(this);
        }
 /// <summary>
 /// Load the specified scene after an (optional) delay.
 /// </summary>
 /// <param name="sceneName"></param>
 /// <param name="delay"></param>
 public void LoadSceneDelayed(string sceneName, float delay = 0)
 {
     if (!Mathf.Approximately(delay, 0))
     {
         StartCoroutine(LoadSceneDelayedCoroutine(sceneName, delay));
     }
     else
     {
         TransitionHelper.LoadScene(sceneName);
     }
 }
예제 #3
0
        /// <summary>
        /// Coroutine that will load a scene and wait unitl it has loaded.
        /// </summary>
        /// <param name="sceneToLoad"></param>
        /// <returns></returns>
        public IEnumerator LoadSceneAndWaitForLoad(string sceneToLoad)
        {
#if UNITY_5_4_OR_NEWER
            UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneFinishedLoading;
#endif
            TransitionHelper.LoadScene(sceneToLoad);
            while (!_newSceneLoaded)
            {
                yield return(null);
            }
            _newSceneLoaded = false;
#if UNITY_5_4_OR_NEWER
            UnityEngine.SceneManagement.SceneManager.sceneLoaded -= OnSceneFinishedLoading;
#endif
        }
        protected override void TransitionCompleted()
        {
            // Only disable the image if we have transitioned in.
            if (Mathf.Approximately(EndValue, 0))
            {
                SetTransitionDisplayedState(false);
            }
            base.TransitionCompleted();

            if (SceneChangeMode == SceneChangeModeType.End)
            {
                Assert.IsFalse(string.IsNullOrEmpty(SceneToLoad), "When setting SceneChangedMode to End you must enter the name of a scene to load.");
                TransitionHelper.LoadScene(SceneToLoad);
            }
            if (SceneChangeMode == SceneChangeModeType.CrossTransition)
            {
                TransitionController.Instance.IsInCrossTransition = false;
            }
        }
        static IEnumerator LoadSceneDelayedCoroutine(string sceneName, float delay)
        {
            yield return(new WaitForSeconds(delay));

            TransitionHelper.LoadScene(sceneName);
        }