Unity3d restart current scene

后端 未结 3 1842
既然无缘
既然无缘 2021-01-20 19:42

Ok so I am trying to restart the scene on R being pressed and for some reason, I am getting errors like, well in the unity console: \"unexpected symbol \'}\' \" and \"parsin

3条回答
  •  佛祖请我去吃肉
    2021-01-20 20:08

    You must ask the scene manager to load the scene using LoadScene

    if (Input.GetKeyDown(KeyCode.R))  
        SceneManager.LoadScene( SceneManager.GetActiveScene().buildIndex ) ;
    

    You were just retrieving the build index of the current scene.

    Also, about yourcompilling error, you have forgotten the semi-colon at the end of the line ;)

提交回复
热议问题