- Home /
Once I paused my game how do I bring up a menu?
For my PauseMenu script I've put in this:
using UnityEngine;
using System.Collections;
public class PauseMenu : MonoBehaviour {
public void PauseGame() {
if(Input.GetKeyUp(KeyCode.Escape)) {
if(Time.timeScale == 1) {
Time.timeScale = 0;
}
else
{
Time.timeScale = 1;
}
}
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
PauseGame();
}
}
Now my question is: Once I pressed the Pause key, which is Escape in this script, how do I make a new menu pop up? And also overlapping/removing other GUI formats for a period of time until the Time.timeScale is set to 1 again?
Comment
Best Answer
Answer by FL · Jan 20, 2013 at 12:58 AM
Just displays the GUI at main camera when paused.
function OnGUI () {
if(Time.timeScale == 0){
... draw the buttons as a standard Unity GUI menu ...
}
}
Example script: http://wiki.unity3d.com/index.php?title=PauseMenu
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Display multiple scenes? 1 Answer
Game Menus WIth Keyboard Input Control 1 Answer
C sharp menu problem with bottons 1 Answer
Multiple Cars not working 1 Answer