Exit application

Hi, i need to exit from an application if i press a key

i wrote this:

	if(Input.GetKey(KeyCode.Space))
	{
		if(pos == 0)
			Application.LoadLevel("Scene");
		else if(pos == 1)
			Application.Quit();
    }

but Application.Quit(); doesn’t work, can someone help me ? thank you:)

You can change your line 6 into the following snippet and it will behave far more intuitively for developer usage. (In that it will feed a message to the developer and explain why nothing is happening.) Stuff like this doesn’t exactly make sense that it’s not in the base engine… But there you have it.

if (Application.isEditor)
  Debug.Log("Attempted to quit from the Editor.")
else if (Application.isWebPlayer)
  Debug.Log("Attempted to quit from the Web Player.")
else
  Application.Quit();

Should be Input.GetKeyDown(KeyCode.Space)) or GetKeyUp (Depending on how you want it).

when you build it should work