- Home /
 
 
               Question by 
               RNVitter · Apr 29, 2014 at 07:24 PM · 
                2drestartside-scrolling  
              
 
              How to make one restart screen for an entire game
I have a separate restart screen with a restart button and a quit button, I want to make it so that the restart button just reloads the last played level and I want to be able to do this for every level of the game
I've tried this code but it did not work
 public class Restart : MonoBehaviour {
 
     void OnMouseDown()
     {
         Application.LoadLevel(Application.loadedLevel); 
     }
 }
 
               I am pretty sure this does not work because when the player dies it opens up a new scene (the restart scene) and the loadedlevel just reloads the restart scene, so how would i reload the previous scene?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by ReContraChanfle · Apr 29, 2014 at 07:49 PM
i have an idea, create a gameobject put it in the scene atach a script with this code:
  public int currentLevel;
 
 void Start()
 {
 currentLevel = Application.LoadedLevel;
 
 
 }
 
 void Awake()
 {
  DontDestroyOnLoad(this);
 }
 
              Your answer