public void NextLevel() { int previous = loadedLevel; int index = previous + 1; if (index >= SceneManager.sceneCountInBuildSettings) { index = 0; //Go to title screen } StartCoroutine(NextLevelLoad()); IEnumerator NextLevelLoad() { portal.EnterPortal(); yield return(new WaitForSeconds(2.1f)); DeactivatePlayer(); AsyncOperation loadingScreen = SceneManager.LoadSceneAsync(1, LoadSceneMode.Additive); while (!loadingScreen.isDone) { yield return(null); } AsyncOperation gameScene = SceneManager.LoadSceneAsync(index, LoadSceneMode.Additive); while (!gameScene.isDone) { yield return(null); } loadedLevel = index; bool stillPlaying = (loadedLevel != 0); yield return(new WaitForSeconds(minLoadTime)); AsyncOperation unloadPrevious = SceneManager.UnloadSceneAsync(previous); while (!unloadPrevious.isDone) { yield return(null); } if (stillPlaying) { if (FindObjectOfType <ParalaxBackground>()) { FindObjectOfType <ParalaxBackground>().Initialize(); } MoveToSpawnPoint(); yield return(new WaitForSeconds(1)); ActivatePlayer(); } else //Back at the main menu { StartCoroutine(RemovePlayerObjects()); } AsyncOperation unloadLoading = SceneManager.UnloadSceneAsync(1); while (!unloadLoading.isDone) { yield return(null); } if (stillPlaying) { portal.ExitPortal(); } } }