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.
UnityEngine.Application.LoadLevel is obsolete, use SceneManager.LoadScene:
using UnityEngine.SceneManagement;
...
SceneManager.LoadScene("Scene_Name");
Use
Application.LoadLevel(Application.loadedLevel);
At 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();