Thats my solutions

Here is my solution:

 private void LoadNextScene()
    {



        switch (state)
        {
            case State.Alive:
                break;
            case State.Dying:
                SceneManager.LoadScene(0);
                break;
            case State.Transcending:
                int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
                int maxSceneCount = SceneManager.sceneCountInBuildSettings;
                int newMax = maxSceneCount - 1;

                print(newMax);

                if (currentSceneIndex >= newMax)
                {
                    SceneManager.LoadScene(0);
                }
                else if (currentSceneIndex <= newMax)
                {
                    print(maxSceneCount);
                    int nextSceneIndex = currentSceneIndex + 1;
                        SceneManager.LoadScene(nextSceneIndex);

                   
                } 

                //int nextSceneIndex = currentSceneIndex + 1;
                //SceneManager.LoadScene(nextSceneIndex);
                //SceneManager.LoadScene(1);
                break;
            default:
                break;
        }

    }

I did something super similar with comparing current scene to max scene. Here’s what I came up with ('currentLevel and sceneCount are set in the Start method).

    void loadNextScene()
    {
        int nextLevel = currentLevel + 1;
        if (nextLevel >= sceneCount)
        {
            SceneManager.LoadScene(0);
        }
        SceneManager.LoadScene(nextLevel);
    }

Privacy & Terms