Unity3d restart current scene

后端 未结 3 1841
既然无缘
既然无缘 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:03

    I can say that the code below might be the easiest method;

    SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    
    0 讨论(0)
  • 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 ;)

    0 讨论(0)
  • 2021-01-20 20:10

    just close the window and restart unity application, simple as that

    0 讨论(0)
提交回复
热议问题