Hey. So I know that I could simply restart my scene by getting the name of the scene and putting it in some script, but I want to use a script that will work on multiple scenes that checks the current scene and restarts it without requiring a scene name. If someone can provide a simple script that performs this action, I will be more than happy.
Cheers.
4 Answers
4UnityEngine.Application.LoadLevel is obsolete, use SceneManager.LoadScene:
using UnityEngine.SceneManagement;
...
SceneManager.LoadScene("Scene_Name");
Use
Application.LoadLevel(Application.loadedLevel);
Hello, I need help @MakerDavid I cant find how to turn off continuous baking in the settings (I'm Using Unity 2017.3)
– RavenHardtAt the top of your file add:
using UnityEngine.SceneManagement;
When you want to restart your scene add:
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
That’s it!
Application.LoadLevel.(Application.loadedLevel); or
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 0);
I don’t know if this works, but
SceneManager.LoadScene(SceneManager.GetActiveScene();
It works, but iu just need to add a ".name" at the end of GetActiveScene. Just like this: SceneManager.LoadScene(SceneManager.GetActiveScene().name);
– LunartSP
Actually, to restart the CURRENT scene, you would do: SceneManager.LoadScene(GetActiveScene().name);
– kevinrocks_786