Challenge with modulus

Here’s what I did for looping levels

private void LoadNextLevel()
    {
        int nextSceneIndex = SceneManager.GetActiveScene().buildIndex + 1;
        int numScenes = SceneManager.sceneCountInBuildSettings;
        SceneManager.LoadScene(nextSceneIndex % numScenes);
    }

Privacy & Terms