How to stop escape button from closing the game?

I don’t know if this is a Unity Personal thing or not, but when I build my game and run it pressing the escape button twice shuts down the game, how do I stop this? I tried searching for a script that is causing this but I can’t find any. I have a pause menu that I want to use for executing an application shutdown and the escape button is interfering a lot.
Please help

That’s not the default behavior. Are you using any 3rd party libraries in your project? If you start a new Unity project with an empty scene, and build it, does the Escape button close out of that as well?

You said you already tried searching for something that would cause this. Did you search for KeyCode.Escape? Did you search for use of Application.Quit()?

If you go to Edit → Project Settings → Input, do any of the inputs respond to the “escape” key? For example:

3433299--271378--upload_2018-3-21_9-18-14.png

If so, is there any code in your project that handles that input? (For example, in this case, you’d search for the work “Cancel”, including the quotes, to see if that input is being consumed by an InputManager call.)

2 Likes

Thanks for reminding me, I searched KeyCode.Escape and turns out Invector asset is controlling the Application.Quit(), problem solved.

Just to specify to another ones who may face this too, the problem is at: vThirdPersonController.cs in the CloseApp method. Just comment/erase this method and it’s call.

Had the same problem. In my case it was a “SimpleCameraController.cs” script that I have no idea why is on my project since it’s a new project, it’s something that was added by Unity during project creation. And why does a “Camera Controller” closes the app on pressing ESC? Why on Earth would that be related to a camera controller script?

4 Likes