1

I have this piece of code for going to the next scene when the space pressed in built index order (for example , scene a is number 0 , scene b is number 1 and ... ) , but it doesn't work .

void Update () {

    if (Input.GetKey (KeyCode.Space)) {
        int nextSceneIndex = SceneManager.GetActiveScene ().buildIndex + 1;
        SceneManager.LoadScene (nextSceneIndex);
        }
    }
arshia9
  • 11
  • 2
  • Do you get some error? Does it change to the wrong scene? Does it change scene at all? What is the code inside `SceneManager.LoadScene`? With a little bit more of detail I could actually help you. – Agustin0987 Sep 16 '16 at 02:36

1 Answers1

1

Add using UnityEngine.SceneManagement; to the top of your script, also make sure you add the level to the build index through file > build options.