- Home /
Answer by yoda12 · Jan 01, 2015 at 09:06 PM
 // Quits the player when the user hits escape
     function Update () {
         if (Input.GetKey ("escape")) {
             Application.Quit();
         }
     }
http://docs.unity3d.com/ScriptReference/Application.Quit.html
Answer by DigitalKnifeInteractive · Jan 01, 2015 at 09:30 PM
you make a empty gameobject and attach this script to it script:
C#: public KeyCode yourButton;
 void Start()
 {
     DontDestroyOnLoad(gameObject); //this makes the GameObject go through all the scenes. That means, this will work in every scene in the game.
 }
 
 void Update()
 {
     if (Input.GetKeyDown(yourButton))
     {
         Application.Quit();
         Debug.Log("Application has been quit!");
     }
 }
JavaScript:
 #pragma strict
 
 var yourButton : KeyCode;
     
 function Start()
 {
     DontDestroyOnLoad(gameObject); //this makes the GameObject go through all the scenes. That means, this will work in every scene in the game.
 }
 
 function Update()
 {
     if(Input.GetKeyDown(yourButton))
     {
         Application.Quit();
         Debug.Log("Application has been quit!");
     }
 }
Your answer
 
 
             Follow this Question
Related Questions
Where is Reference Resolution in new version? 1 Answer
WWW Delete and Put 0 Answers
How to Bind 3rd (hidden) uv channel in shader? 1 Answer
I cannot download items 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                