Why is my script not working?
using UnityEngine; using System.Collections;
public class PauseMenu : MonoBehaviour {
public string mainMenu;
public bool isPaused;
public GameObject pauseMenuCanvas;
// Update is called once per frame
void Update ()
{
if (isPaused) {
pauseMenuCanvas.SetActive (true);
} else
pauseMenuCanvas.SetActive (false);
}
if(Input.GetKeyDown(KeyCode.Escape))
{
isPaused = !isPaused;
}
public void Resume ()
{
isPaused = false;
}
public void Exit ()
Application.LoadLevel(mainMenu);
}
Could you please be more specific? Is there an error message? What is the desired function, and then what is it actually doing?
Answer by EvilTak · Aug 30, 2015 at 10:11 AM
There's an extra } after the else where you set the pauseMenuCanvas to inactive (line 14 in the code in the question. Please post all errors regarding your script as it comes up in the editor and do not post such "Check My Code!" questions without proper information, Googling a solution yourself and trying your best to solve the problem.
Your answer
Follow this Question
Related Questions
Accessing script from another object 1 Answer
Help with Script 0 Answers
this script is missed up help? 1 Answer
Object reference not set to instance for my timer and my text 0 Answers
Displaying Text on Touch Event 0 Answers