private void LoadScenes(GameSceneSO[] locationsToLoad, bool showLoadingScreen) { _activeScene = locationsToLoad[0]; UnloadScenes(); if (showLoadingScreen) { _loadingScreenManager.ToggleLoadingScreen(true); } if (_scenesToLoadAsyncOperations.Count == 0) { for (int i = 0; i < locationsToLoad.Length; i++) { string currentScenePath = locationsToLoad[i].scenePath; _scenesToLoadAsyncOperations.Add(SceneManager.LoadSceneAsync(currentScenePath, LoadSceneMode.Additive)); } } // Load persistent scenes in case some of them were unloaded. for (int i = 0; i < _persistentScenes.Count; i++) { if (!IsSceneLoaded(_persistentScenes[i].scenePath)) { _scenesToLoadAsyncOperations.Add(SceneManager.LoadSceneAsync(_persistentScenes[i].scenePath, LoadSceneMode.Additive)); } } StartCoroutine(WaitForLoading(showLoadingScreen)); }
void LoadManagerScene() { List <GameSceneSO> scenesToLoad = new List <GameSceneSO>(); for (int i = 0; i < ManagerScenes.Length; i++) { GameSceneSO sceneSO = ManagerScenes[i]; for (int j = 0; j < SceneManager.sceneCount; j++) { Scene scene = SceneManager.GetSceneAt(j); if (scene.path == sceneSO.scenePath) { return; } else if (j == SceneManager.sceneCount - 1) { scenesToLoad.Add(sceneSO); IsEditorInitializationMode = true; } } } foreach (GameSceneSO sceneSO in scenesToLoad) { SceneManager.LoadScene(sceneSO.scenePath, LoadSceneMode.Additive); } }
private void LoadScenes(GameSceneSO[] locationsToLoad, bool showLoadingScreen) { _activeScene = locationsToLoad[0]; UnloadScenes(); if (showLoadingScreen) { _loadingScreenManager.ToggleLoadingScreen(true); } if (_scenesToLoadAsyncOperations.Count == 0) { foreach (GameSceneSO location in locationsToLoad) { _scenesToLoadAsyncOperations.Add(SceneManager.LoadSceneAsync(location.scenePath, LoadSceneMode.Additive)); } } StartCoroutine(WaitForLoading(showLoadingScreen)); }