- Home /
how to make quit game
how to my game press esc and quit that very simple give me a script and tutorial
Comment
Best Answer
Answer by CodeMasterMike · Dec 10, 2012 at 12:34 PM
function Update ()
{
if(Input.GetKeyDown(KeyCode.Escape) == true)
{
Application.Quit();
}
}
Link to Application documentation
Good luck!
Answer by Iceblitzyt · Dec 10, 2012 at 12:44 PM
Here's a c# version of a Quit button.
void OnGUI(){
if(GUI.Button(new Rect((Screen.width) /2, (Screen.height)/2, 50, 50), "Quit Game")){
Appliation.Quit();
}
}
This is the verson where you press escape to make it quit.
void Update() {
if(Input.Getkeydown("Escape Key"){
Application.Quit;
}
}
For more variations check the unity scripting refrence.
Thanks, but Intellisense reckons you need the brackets after "Quit" in the second version :) Application.Quit();
Your answer
