system
1
Hi
I feel oh so incredibly stupid to have to ask this, so please don't remind me!
I've made a little game that I want to be able to send off etc, but when I run my builds (finished non-debug exe files) when I press the escape key, nothing happens. What do I need to add to the file to have it exit on the escape key, or do anything on the escape key (so I can have it go to a menu, where pressing exit will close the game)
Thanks
jashan
2
What you need:
So, what you'd probably end up is a script which implements that following Update()-method (and is attached to some game object that's available all the time):
public void Update() {
if (Input.GetKeyDown(KeyCode.Escape)) {
Application.Quit();
}
}
The JavaScript version of the same can be found in the documentation of Application.Quit (see above). It's using Input.GetKey instead of Input.GetKeyDown and also uses the version which takes the name of the key instead of the keycode (I guess that's kind of the JavaScript way of doing things ... put a typo in "escape" and it'll break and you'll spend hours debugging ... well, maybe you'll get a nice runtime error and debugging will only take a few moments ;-)
for some reason it doesn’t work i have tried key/keydown/ keycode with and without " " and no succes maybe i do something wrong?
Regah
4
i tried the same, but my game has a first person camera which when i press esc it makes my mouse visible back again taking me out of game mode, so the esc thing does not work
do any of you have any solutions?