public void QuitGameplay() { if (lastActiveScene.isLoaded) { UnloadScene(lastActiveScene); lastActiveScene = null; } }
private void SetActiveScene(SceneListItem sceneToSet, bool setActive) { if (setActive) { SceneManager.SetActiveScene(sceneToSet.scene); MarkArrayIndexAsActive(sceneToSet); } //listenerManager.ParseListeners(otherScenes[index].scene, setActive); }
private void UnloadAllOtherGameplayScenes(SceneListItem sceneToKeep) { foreach (SceneListItem item in sceneLibrary) { if (item != sceneToKeep && item.isGameplayScene && item.isLoaded) { UnloadScene(item); } } }
private void MarkArrayIndexAsActive(SceneListItem activeScene) { foreach (SceneListItem item in sceneLibrary) { if (item != activeScene) { item.isActive = false; } else { item.isActive = true; } } }
private IEnumerator LoadNewSceneAdditive(SceneListItem newScene, bool isActive, bool isGameplay) { if (!newScene.isLoaded) { AsyncOperation asyncOp; asyncOp = SceneManager.LoadSceneAsync(newScene.sceneName, LoadSceneMode.Additive); asyncOp.allowSceneActivation = false; yield return(MonitorLoadingOfScene(asyncOp)); //change status @90% asyncOp.allowSceneActivation = true; yield return(CheckIfLoadIsDone(asyncOp)); } GetSceneAndIndexOfScene(newScene); //only available when loaded SetActiveScene(newScene, isActive); SetSceneLoaded(newScene, true); SetSceneGameplay(newScene, isGameplay); UpdateListeners(newScene); }
private void UpdateListeners(SceneListItem sceneItem) { listenerManager.UpdateListeners(sceneItem.scene); }
private void SetSceneGameplay(SceneListItem item, bool isGameplay) { item.isGameplayScene = isGameplay; }
private void SetSceneLoaded(SceneListItem item, bool isLoaded) { item.isLoaded = isLoaded; }
private void UnloadScene(SceneListItem sceneToUnload) { onSceneUnloaded?.Invoke(sceneToUnload.sceneName); SetSceneLoaded(sceneToUnload, false); SceneManager.UnloadSceneAsync(sceneToUnload.sceneName); }
private void GetSceneAndIndexOfScene(SceneListItem item) { item.scene = SceneManager.GetSceneByName(item.sceneName); item.sceneIndex = item.scene.buildIndex; }
public void CloseOptionsMenu() { SetActiveScene(lastActiveScene, true); lastActiveScene = menuScene; }
public void LoadOptionsMenu() { lastActiveScene = GetActiveScene(); StartCoroutine(LoadNewSceneAdditive(menuScene, true, false)); }