Esempio n. 1
0
 public void AddSceneToLibrary(SceneAsset sceneAsset)
 {
     if (!m_sceneLibrary.Contains(sceneAsset))
     {
         m_sceneLibrary.Add(sceneAsset);
     }
 }
Esempio n. 2
0
 public void UnloadScene(SceneAsset scene)
 {
     scene.OnUnload();
     SceneManager.UnloadSceneAsync(scene.SceneName());
     scene.SetActive(false);
     m_sceneLibrary.SetAsUnloaded(scene);
 }
Esempio n. 3
0
        public IEnumerator LoadAdditive(SceneAsset scene, bool setActiveOnLoad)
        {
            m_sceneLibrary.AddSceneToLibrary(scene);

            m_pausedForLoadingEvent.Raise(true);

            AsyncOperation asyncOp;

            asyncOp = SceneManager.LoadSceneAsync(scene.SceneName(), LoadSceneMode.Additive);

            asyncOp.allowSceneActivation = false;

            yield return(MonitorLoadingOfScene(asyncOp));    //change status @90%

            asyncOp.allowSceneActivation = setActiveOnLoad;

            yield return(CheckIfLoadIsDone(asyncOp));

            //update the scene asset
            m_sceneLibrary.SetAsLoaded(scene);
            var sceneRef = SceneManager.GetSceneByName(scene.SceneName());

            scene.SetSceneRef(sceneRef);
            if (setActiveOnLoad)
            {
                SceneManager.SetActiveScene(sceneRef);
                m_sceneLibrary.SetActiveScene(scene);
            }
            scene.OnLoad();

            m_pausedForLoadingEvent.Raise(false);
        }
Esempio n. 4
0
 public void SetAsUnloaded(SceneAsset scene)
 {
     scene.SetLoaded(false);
     if (m_loadedScenes.Contains(scene))
     {
         m_loadedScenes.Remove(scene);
     }
 }
Esempio n. 5
0
 public void SetAsLoaded(SceneAsset scene)
 {
     scene.SetLoaded(true);
     if (!m_loadedScenes.Contains(scene))
     {
         m_loadedScenes.Add(scene);
     }
 }
Esempio n. 6
0
 public void SetActiveScene(SceneAsset activeScene)
 {
     foreach (SceneAsset scene in m_sceneLibrary)
     {
         if (scene == activeScene)
         {
             scene.SetActive(true);
         }
         else
         {
             scene.SetActive(false);
         }
     }
 }
Esempio n. 7
0
        private IEnumerator TransitionBetweenScenes(SceneAsset newScene, SceneAsset oldScene)
        {
            m_transitionToBlack.Raise();
            yield return(new WaitForSeconds(m_transitionDurationVar.Value));

            yield return(StartCoroutine(sceneLoader.LoadAdditive(newScene, true)));

            while (!newScene.IsLoaded())
            {
                yield return(null);
            }

            sceneLoader.UnloadScene(oldScene);

            m_transitionBackToView.Raise();
            yield return(new WaitForSeconds(m_transitionDurationVar.Value));
        }
Esempio n. 8
0
 private IEnumerator LoadScene(SceneAsset scene, bool setActiveOnLoad)
 {
     yield return(StartCoroutine(sceneLoader.LoadAdditive(scene, setActiveOnLoad)));
 }