2016-09-14 54 views
0

我有这段代码当按下内置的索引顺序(例如,场景a是数字0,场景b是数字1和数字)时,转到下一个场景。 ..),但它不起作用。去建立的索引顺序中的下一个场景

void Update() { 

    if (Input.GetKey (KeyCode.Space)) { 
     int nextSceneIndex = SceneManager.GetActiveScene().buildIndex + 1; 
     SceneManager.LoadScene (nextSceneIndex); 
     } 
    } 
+0

你有错误吗?它是否改变为错误的场景?它是否改变场景? “SceneManager.LoadScene”里面的代码是什么?多一点细节可以帮助你。 – Agustin0987

回答

0

添加using UnityEngine.SceneManagement;到脚本的顶部,也确保你通过文件级别添加到生成指数>构建选项。