/// <summary> /// Loads a scene if it has never been loaded before. /// </summary> /// <param name="sceneName">The name of the new scene to load</param> private static void LoadNewScene(string sceneName) { // Let anyone that cares know that a scene change has started. if (SceneChangeStarted != null) { SceneChangeStarted.Invoke(); } // Load the scene asynchronously AsyncOperation loadNewScene = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); instance.StartCoroutine(WaitUntilSceneIsLoaded(sceneName, loadNewScene)); }
/// <summary> /// Enables a scene if it has already been loaded, and disables the old one. /// </summary> /// <param name="sceneName">The name of the scene to enable</param> private static void LoadExistingScene(string sceneName) { // Let anyone that cares know that a scene change has started. if (SceneChangeStarted != null) { SceneChangeStarted.Invoke(); } Scene currentScene = SceneManager.GetActiveScene(); Scene newScene = SceneManager.GetSceneByName(sceneName); //Disable the current scene and load the new one DisableAndEnable(currentScene, newScene); }