I did it a little differently and it worked. What do you think?

Hello! My solution for looping through scenes was a little different but it worked. I was curious what others though, Thanks!

    private void LoadNextLevel()
        int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
        int nextSceneIndex = currentSceneIndex + 1;

        if (currentSceneIndex <= 1)
            SceneManager.LoadScene(nextSceneIndex); // todo allow for more than 2 levels

Hi Craig,

If your solution works, it’s valid. What is the 1 in the first condition referring to? The highest index in the build settings list? If so, you could replace the hard-coded value by (SceneManager.sceneCountInBuildSettings - 1). Apart from this detail, I cannot spot any issue with your code. Well done. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms