Question by
JosephLim · Feb 11, 2017 at 06:10 AM ·
2d-platformerpause menu
Main Menu button does not load main menu properly.
ive been working on a 2D platformer, currently I'm stuck on the pause function of the game that includes a main menu button to return to the main menu.
But, every time I press on the main menu button, it loads the main menu but it doesn't play at all, as though the menu has been paused or something. I am not sure what is the problem right now.
Here is my script. please help out! thanks ! using UnityEngine; using System.Collections; using UnityEngine.SceneManagement;
public class pause : MonoBehaviour {
public GameObject PauseUI;
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 (){
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex) ;
}
public void Menu(){
SceneManager.LoadScene (0);
}
public void Quit(){
Application.Quit ();
}
}
Comment
my pause button is in the input of unity which is escape or p
Your answer