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 ;)
I can say that the code below might be the easiest method;
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With