Restarting a scene from the start using scenemanager

#pragma strict
import UnityEngine.SceneManagement;
import System.Collections;

function Update(){
    
}

function OnGUI() {
    while (GUI.Button(new Rect(Screen.width*0.5,Screen.height*0.5,Screen.width*0.05,Screen.height*0.1), "MainMenu") ){
        SceneManager.UnloadScene(0);
        SceneManager.LoadScene(0);
       
      
    }
}

so my problem is using the script i currently have all it does is “alt tab” through the scenes instead of actually restart the scene from the start (timer keeps going down from where it is not from the start postion, buttons dont show up like they should when the scene is loaded etc). so my question is this how do i get it to completely unload the scene and load the scene from the start with the timer and gui buttons all showing like they should? like it did with application.loadlevel?

Try using this

SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex);

This will restart the whole scene.

Hope it helps :slight_smile: