Restart a Scene
So , i've created a pause menu and a button in it to restart the level , but when i press it loads paused and in the point i've paused it . I want a code to restart the scene and not to load it from that point . Any ideas guys ?
Answer by angelromp06 · Jun 06, 2020 at 05:32 PM
If I understood well, you want add in the button a function that restarts thr scene-level. To do this create the following public void:
public void Restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
But you should also write in the first lines of your script (a line under "using UnityEngine;") :
using UnityEngine.SceneManagement;
and add your scene to the build settings to work
Your answer
Follow this Question
Related Questions
How do you link scenes together? 3 Answers
How to keep overlay menu as I load different scenes. 0 Answers
How to call a public function automatically when I return to the Main Menu from any levels? 3 Answers
How do I add my script to the "Assets/Create" menu? 2 Answers
UnityEngine.Application.LoadLevel(String) is obsolet! 1 Answer