Can anyone tell me if there is a way to send a command to quit the Unity application (desktop game) with out using “escape”. I am setting up a demonstration that will be controlled from a basic game controller and wish to avoid access to a keyboard. I have tried mapping and scripting various key/input combinations without success and am beginning to think it might not be possible! Or am I missing something obvious?
A call to Application.Quit should shut down the desktop player. The logic behind when and how your game calls Application.Quit is entirely up to you. You should be able to wire it to any input (or other piece of game logic) you need. What does the code look like that you’re trying to use?
Thank for this - at least I can keep trying. the coding I am using is straight out of the reference manual - I am a novice coder but getting by mostly! Here is the last effort.
// Quits the player when the user hits escape/ changed to “Fire2” (set at the project settings to left and right ctlr
function Update () {
if (Input.GetKey (“Fire2”)) {
Application.Quit();
}
}
In addition, you really probably want “GetButtonDown” instead of “GetButton”. The former fires only once during the single frame when the button is first pressed, while the latter fires during each frame where the button is down.
Great - Many thanks - I should have thought - that’s the trouble copying code and not properly learning it - I must get down to it. Works just fine now.
Or you can put a box collider and use OnMouseDown and put your codes in there. So when player clicks on a certain mesh or even a cube in your scene, its get triggered.