Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Make an exit button?

Discussion in 'Scripting' started by Treasureman, Feb 6, 2015.

  1. Treasureman

    Treasureman

    Joined:
    Jul 5, 2014
    Posts:
    563
    I have a script that makes you switch scenes when a key is press. Here it is
    Code (JavaScript):
    1. function Update() {
    2. if(Input.GetKey("escape")){
    3. Application.LoadLevel("Dream Menu (Controls)");
    4. }
    5. }
    How would I make it exit the game instead of switching scenes?
     
  2. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,548
    Code (JavaScript):
    1. if(Input.GetKeyDown(KeyCode.Escape)){
    2. Application.Quit();
    3. }
     
  3. Treasureman

    Treasureman

    Joined:
    Jul 5, 2014
    Posts:
    563
    I tried it but it did nothing. I didn't get an error or anything, but it just didn't do anything
     
  4. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,548
    Are you trying it in the Editor?

    Application.Quit is ignored in the editor. It only works on actual builds.