public void StartGame()
    {
        StartCoroutine(StartGameLoad());
        IEnumerator StartGameLoad()
        {
            AsyncOperation loadingScreen = SceneManager.LoadSceneAsync(1, LoadSceneMode.Additive);

            while (!loadingScreen.isDone)
            {
                yield return(null);
            }

            AsyncOperation loadPlayer = SceneManager.LoadSceneAsync(2, LoadSceneMode.Additive);

            while (!loadPlayer.isDone)
            {
                yield return(null);
            }

            player = PlayerStatusManager.Instance.Player;
            portal = player.gameObject.GetComponent <PortalController>();

            AsyncOperation gameScene = SceneManager.LoadSceneAsync(3, LoadSceneMode.Additive);

            while (!gameScene.isDone)
            {
                yield return(null);
            }

            loadedLevel = 3;
            MoveToSpawnPoint();
            ActivatePlayer();

            yield return(new WaitForSeconds(minLoadTime));

            AsyncOperation unloadMenu = SceneManager.UnloadSceneAsync(0);

            while (!unloadMenu.isDone)
            {
                yield return(null);
            }
            AsyncOperation unloadLoading = SceneManager.UnloadSceneAsync(1);

            while (!unloadLoading.isDone)
            {
                yield return(null);
            }
            portal.ExitPortal();
        }
    }
    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();
            }
        }
    }