- Home /
Question by
ABDESSAMAAJAKANE · Aug 15, 2018 at 11:44 PM ·
unity 2dpause menu
make a clickable button that makes pause menu appears.,How can i make a pause button on my game screen than shows pause menu when i click it?
i want to make a buuton that its clickable and it shows my pause menu, i have created a pause menu that appears when i click on my keyborrd but i want that to hapen also when i build the game on android this is the script m using.
Comment
Answer by ABDESSAMAAJAKANE · Aug 15, 2018 at 11:46 PM
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.LoadLevel (Application.loadedLevel);
}
public void MainMenu(){
Application.LoadLevel (0);
}
public void Quit(){
Application.Quit ();
}
}
Your answer
Follow this Question
Related Questions
Interactible Pause menu 0 Answers
Unity 2D - Pivot points based on slice, not on original texture. 0 Answers
Camera Effects for 2d 0 Answers
Unity 4.3, generate 2d mesh 2 Answers
2D C# Jump Script Addforce 2 Answers