When building a game for Windows, is there a standard way to exit the game? (such as Escape)
I usually find myself ALT-tabbing away from the game.
Thanks.
When building a game for Windows, is there a standard way to exit the game? (such as Escape)
I usually find myself ALT-tabbing away from the game.
Thanks.
Alt F4
I found that this code worked for me:
{ if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } }
Edit to add: I forgot to mention that this goes in the “Void Update()” section
I’m not sure about having the Escape key end the game. Windows based gamers would normally expect the Escape key to pause the game and show a menu with various options. One of those options would be a button to click to end the game.
It depends on the users I guess. Most of the windows dektop games I have played, and all of the desktop games I build, use Escape. In game Esc takes you back to the Title Screen / Main Menu. At the TS/MM Esc exits the application.
Since the opening post suggested the escape key, that’s the code I gave him. It isn’t exactly a Herculean task to change the keycode for another key, but at least it pointed the poster in the right direction!
Thats not really right direction. In Windows there should be no other exit button in keyboard other than the standard system combination in 2nd post (works automatically). Normal way to exit a game is always from some menu which usually appears with ESC or from some UI button.
Oh, right. Sorry, I didn’t realise that. Since I only suggested the code because I’m using it on my first attempt at a Unity game, I guess I’d better investigate UI buttons, and remove the evil code! Thanks for the correction. ![]()