public void AddSceneToLibrary(SceneAsset sceneAsset) { if (!m_sceneLibrary.Contains(sceneAsset)) { m_sceneLibrary.Add(sceneAsset); } }
public void UnloadScene(SceneAsset scene) { scene.OnUnload(); SceneManager.UnloadSceneAsync(scene.SceneName()); scene.SetActive(false); m_sceneLibrary.SetAsUnloaded(scene); }
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); }
public void SetAsUnloaded(SceneAsset scene) { scene.SetLoaded(false); if (m_loadedScenes.Contains(scene)) { m_loadedScenes.Remove(scene); } }
public void SetAsLoaded(SceneAsset scene) { scene.SetLoaded(true); if (!m_loadedScenes.Contains(scene)) { m_loadedScenes.Add(scene); } }
public void SetActiveScene(SceneAsset activeScene) { foreach (SceneAsset scene in m_sceneLibrary) { if (scene == activeScene) { scene.SetActive(true); } else { scene.SetActive(false); } } }
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)); }
private IEnumerator LoadScene(SceneAsset scene, bool setActiveOnLoad) { yield return(StartCoroutine(sceneLoader.LoadAdditive(scene, setActiveOnLoad))); }