am doing a game where if i press esc button a message box will popup showing two buttons RESUME and QUIT. i have done the script without the popup. need help.
using UnityEngine;
using System.Collections;
public class pause_script : MonoBehaviour {
bool gamePaused = false;
public float pauseBoxWidth = 250;
public float pauseBoxHeight = 150;
public float resumButtonWidth = 250;
public float resumeButtonHeight = 200;
public float resumeButtonWidhtOffset = 100;
public float resumeButtonHeightOffset = 100;
public Texture pauseTexture;
public Texture resumeButtonTexture;
public Texture mainMenuButton;
public GUIStyle myStyle;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.Escape))
{
if(gamePaused)
{
Time.timeScale = 1;
gamePaused = false;
}
else if(!gamePaused)
{
Time.timeScale = 0;
gamePaused = true;
}
}
}
void OnGUI()
{
if(gamePaused == true)
{
GUI.Box(new Rect((Screen.width / 2) - (pauseBoxWidth / 2),
(Screen.height / 2) - (pauseBoxHeight / 2 ), pauseBoxWidth, pauseBoxHeight), pauseTexture, myStyle);
GUI.Button(new Rect(((Screen.width / 2) - (resumButtonWidth / 2)) - resumeButtonWidhtOffset,
((Screen.height / 2) - (resumeButtonHeight / 2)) - resumeButtonHeightOffset,
resumButtonWidth, resumeButtonHeight),
resumeButtonTexture, myStyle);
}
}
}