- Home /
Why I cannot close program through close button?
public class Exit : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI () {
if(GUI.Button(new Rect(Screen.width-55,Screen.height-40,50,30),"Exit")){
Application.Quit();
}
}
}
I create an exit button to quit game. The button show on the screen, but the button doesn't work when I click it.
I say it's a good question and you have good answers answer for me too shame on you, you didn't mark them as accepted
Answer by Piflik · Aug 29, 2012 at 10:54 AM
Are you trying this from the Editor, or in a built exe? Application.Quit() doesn't do anything in editor.
$$anonymous$$any years later, you just saved me from insanity haha. I was trying so hard to find what i did wrong. thx
Answer by kristercollin · Aug 29, 2012 at 10:59 AM
Could you be specific about where/how you're testing the button? It only works in a built application, but not if you're testing in the editor or on an application that is being accessed by the web player.
So, if it's not working in the editor then build and run the application and then try it, it should work perfectly :)
Answer by Nobody99 · Aug 29, 2012 at 02:03 PM
The game buttons will work only when you build your game so it will not work in the editor if you finished your game you can click build and run
Your answer
Follow this Question
Related Questions
About Application.LoadLevel() 1 Answer
Get the NAMES of levels programmatically 1 Answer
Application.persistentDataPath is empty 4 Answers
Restart your Application via Script 1 Answer
Levels, stages, scenes 0 Answers