public void BackToHome() { Time.timeScale = 1; GameScore.LvlCompleted = false; PrefabPoolingSystem.Reset(); StartCoroutine(LoadAsynchronously(0)); }
private void Awake() { _instance = this; PrefabPoolingSystem.Reset(); _resetBonusCntLimit = _bonusCntLimit; StartGame(); }
IEnumerator LoadGameInBackground(int previousSceneIndex) { // Reset Static Vars PrefabPoolingSystem.Reset(); gameSession.ResetGame(); //------------------------- AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(1, LoadSceneMode.Additive); asyncLoad.allowSceneActivation = false; // Wait until the scene fully loads // (Stops at 0.9 due to allowSceneActivation = false) while (asyncLoad.progress < 0.9f) { yield return(null); } // Wait for Input // (the player press "Play") while (!startGame) { yield return(null); } // Wait a Frame until the Scene is Active yield return(asyncLoad.allowSceneActivation = true); // Optional //SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(1)); // Wait a Frame until the previous Scene is Unloaded Scene previousScene = SceneManager.GetSceneByBuildIndex(previousSceneIndex); if (previousScene.isLoaded) { yield return(SceneManager.UnloadSceneAsync(previousSceneIndex)); } musicPlayer.PlayGame(); startGame = false; }
public void LoadLevel(int sceneIndex) { Time.timeScale = 1; PrefabPoolingSystem.Reset(); StartCoroutine(LoadAsynchronously(sceneIndex)); }