public IEnumerator UnloadScene(ManagedScenes scene) { AsyncOperation asyncUnload = SceneManager.UnloadSceneAsync((int)scene); while (!asyncUnload.isDone) { Debug.Log("Scene Unload Progress: " + (asyncUnload.progress * 100) + "%"); yield return(null); } Debug.Log("Scene Unloaded: " + scene); SceneUnloaded = true; }
public IEnumerator LoadScene(ManagedScenes scene, LoadSceneMode sceneMode = LoadSceneMode.Additive) { while (unloadNeeded && !SceneUnloaded) { yield return(null); } AsyncOperation asyncLoad = SceneManager.LoadSceneAsync((int)scene, sceneMode); asyncLoad.allowSceneActivation = false; while (asyncLoad.progress < 0.9f) { Debug.Log("Scene Load Progress: " + (asyncLoad.progress * 100) + "%"); yield return(null); } asyncLoad.allowSceneActivation = true; Debug.Log("Scene Loaded: " + scene); SceneLoaded = true; }