I'm having trouble getting my "Restart" button to work
Hi there, this is my first time posting here so please forgive me if I'm doing something wrong.
I'm currently making a pause menu for my game. I have four buttons; Resume, Restart, Main Menu and Exit. I have code for all four and it looks to me like it should be working.
 using UnityEngine;
 using System.Collections;
 
 public class pauseMenu : MonoBehaviour {
 
     public GameObject pauseUI;
     
     private bool paused = false;
     
     void Start(){
         
         pauseUI.SetActive(false);
         
     }
     
     
     void Update() {
         
         if(Input.GetButtonDown("Pause")){
             paused = !paused;
         }
         
         if(paused){
             pauseUI.SetActive(true);
             Time.timeScale = 0;
         }
         
         if(!paused){
             pauseUI.SetActive(false);
             Time.timeScale = 1;
         }
         
     }
     
     public void Resume(){
         
         paused = false;
         
     }
     
     public void Restart(){
         
         Application.LoadlLevel(Application.LoadedLevel);
         
     }
     
     public void MainMenu(){
         
         Application.LoadLevel(0);
         
     }
     
     public void Quit(){
         
         Application.Quit();
         
     }
     
 }
 
However, when I try to run the game in Unity I get this error:
"Assets/Scripts/pauseMenu.cs(43,29): error CS0117: UnityEngine.Application' does not contain a definition for LoadlLevel'"
There is something wrong with the Restart button code but I do not know what.
Any help would be appreciated.
Answer by strupan · Dec 10, 2015 at 06:08 PM
 public void Restart(){
          
          Application.LoadlLevel("whatever your level is called");
          
      }
so if your level is called LoadedLevel then
     public void Restart(){
              
              Application.LoadlLevel("LoadedLevel");
              
          }
http://docs.unity3d.com/ScriptReference/Application.LoadLevel.html
Answer by Bleackk · Feb 15, 2016 at 10:04 PM
This restart function does not work on Unity 5 anymore. Here's something I made for a restart Button in another game hope it helps
 using UnityEngine;
 using UnityEngine.SceneManagement; // this is very important so write this here
 using System.Collections;
 
 public class GameController : MonoBehaviour { // my object class.
 
 ================================
 //then in void Update()
     void Update ()
     {
             if (Input.GetKeyDown (KeyCode.R))  // R is a button of Example, choice is yours.
             {
                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
             }
     }
 }
Also, remember to check if you have MORE THANK ONE scene, if yes then check the API docs for further instructions
http://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.html
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                