- Home /
The question is answered, right answer was accepted
In game pause menu
what do i add to this script to make my game pause?
/* GUI.Pause example */
function OnGUI () { if (GUI.Button (Rect (25, 25, 100, 30), "Pause")) { // This code is executed every frame that the Pause remains clicked } }
Answer by peacemaker · Oct 21, 2010 at 02:52 PM
Take a look at this answer: http://answers.unity3d.com/questions/15963/pause-button-script
Basically, you want to set:
Time.timeScale = 0.0;
to pause and :
Time.timeScale = 1.0;
To resume.
Answer by 777Vortex777 · Apr 13, 2014 at 05:40 AM
My In Game Pause Menu. There is a button to activate it up in the Upper Right hand cornor and you can press "P" to bring it up hope you all enjoy if you want to change were the main menu takes you just change it to the level you want it in the build settings you can get the number it is on line 22
var paused : boolean = false;
if(GUI.Button(Rect(1835,20,80,20),"Pause"))
{
paused = true;
}
if(Input.GetKey("p"))
{
paused = true;
}
if(paused == true)
{
GUI.Box(Rect(810,75,300,400),"Menu");
if(GUI.Button(Rect(920,100,80,20),"Resume"))
{
paused = false;
}
if(GUI.Button(Rect(920,130,80,20),"Main Menu"))
{
Application.LoadLevel(0);
}
if(GUI.Button(Rect(920,160,80,20),"Quit"))
{
Application.Quit();
}
}
if(paused == true)
{
Time.timeScale = 0;
}
if(paused == false )
{
Time.timeScale = 1;
}
This post is almost 4 years old and there hundreds of pause game Q&A already.
Follow this Question
Related Questions
Audio keeps playing when paused 1 Answer
why cant i play my scene? 2 Answers
Stop play procedure from within a script 0 Answers
When i press play it just pauses right after. 6 Answers
Pause Button Script 4 Answers