Hey guys, I have a script but I want to add that when I push “p” it shows text “resume game” and “quit game” but I need help with the script, this is my script so far:
Script: #pragma strictvar TS : float; // Time.timeScalevar paused : boolean; //If - Pastebin.com
Thanks, Dean
1 Answer
1
Use OnGUI to draw your buttons and show them.
Your OnGUI function will look something like:
function OnGUI()
{
if(paused)
{
if(GUI.Button(new Rect(10, 10, 100, 30), "Resume Game"))
{
paused = false;
}
if(GUI.Button(new Rect(10, 10, 100, 30), "Quit Game"))
{
Application.Quit();
}
}
}
Thanks for that :D last question, which is the x, y, z? (10, 10, 100, 30) how do i center them both, one on top of eachother? (Scripting noob) Thanks again :)
– Deanfordand also how to change the design of them, thanks haha :'D
– DeanfordMost of your questions are answered here at [GUI Button][1] You can center a button using Screen.height and Screen.width. Just need to make some simple computation here using those. Consider it as an exercise for you. ;-) [1]: http://docs.unity3d.com/ScriptReference/GUI.Button.html
– HarshadKHaha, thanks for your help :D
– Deanford