private void NotifyUnloadEnd(SceneBundle sceneBundle) { isUnloadingWorld = false; if (OnUnloadingEnded != null) { OnUnloadingEnded(sceneBundle); } }
private void NotifyUnloadStart(SceneBundle sceneBundle) { isUnloadingWorld = true; if (OnUnloadingStarted != null) { OnUnloadingStarted(sceneBundle); } }
private IEnumerator UnloadRoutine(SceneBundle sceneBundle) { NotifyUnloadStart(sceneBundle); foreach (var scene in sceneBundle.Scenes) { var sceneToUnload = SceneManager.GetSceneByName(scene.Name); if (sceneToUnload.isLoaded) { yield return(SceneManager.UnloadSceneAsync(scene.Name)); } } NotifyUnloadEnd(sceneBundle); }
private IEnumerator LoadRoutine(SceneBundle sceneBundle) { NotifyLoadStart(sceneBundle); foreach (var scene in sceneBundle.Scenes) { var sceneToLoad = SceneManager.GetSceneByName(scene.Name); if (!sceneToLoad.isLoaded) { yield return(SceneManager.LoadSceneAsync(scene.Name, LoadSceneMode.Additive)); } } if (sceneBundle.SetFirstAsActive && sceneBundle.Scenes.Any()) { var sceneToMakeActive = SceneManager.GetSceneByName(sceneBundle.Scenes[0].Name); if (sceneToMakeActive.isLoaded) { SceneManager.SetActiveScene(sceneToMakeActive); } } NotifyLoadEnd(sceneBundle); }
/// <summary> /// Reload a Scene Bundle. /// /// If one of the scenes in this bundle is not loaded, it is loaded. This keeps every scene /// currently loaded that is not in this bundle untouched. /// /// This is asynchronous. Calling this starts a new thread. /// </summary> /// <param name="sceneBundle">Scene Bundle</param> public void Reload(SceneBundle sceneBundle) { Switch(sceneBundle, sceneBundle); }
/// <summary> /// Unload a Scene Bundle, and immediatly after loads an other Scene Bundle. See <see cref="Load"/> and /// <see cref="Unload"/> for details about how this is done. /// </summary> /// <param name="oldSceneBundle">Scene Bundle to unload.</param> /// <param name="newSceneBundle">Scene Bundle to load.</param> public void Switch(SceneBundle oldSceneBundle, SceneBundle newSceneBundle) { StartCoroutine(SwitchRoutine(oldSceneBundle, oldSceneBundle)); }
/// <summary> /// Unload a Scene Bundle. /// /// If one of the scenes in this bundle is not loaded, it is ignored. /// /// This is also asynchronous. Calling this starts a new thread. /// </summary> /// <param name="sceneBundle">Scene Bundle</param> public void Unload(SceneBundle sceneBundle) { StartCoroutine(UnloadRoutine(sceneBundle)); }
private IEnumerator SwitchRoutine(SceneBundle oldSceneBundle, SceneBundle newSceneBundle) { yield return(UnloadRoutine(oldSceneBundle)); yield return(LoadRoutine(newSceneBundle)); }
protected override void Initialize() { sceneBundle = target as SceneBundle; }