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 "parsing error". But then in Microsoft visual studio I'm getting "; expected". Any ideas of what's wrong with the following code?
void Update() {
if (Input.GetKeyDown(KeyCode.R))
SceneManager.GetActiveScene().buildIndex
}
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 ;)
我可以说下面的代码可能是最简单的方法;
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
只需关闭窗口并重新启动统一应用程序,就这么简单
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.