Use the Escape button to exit a game in Unity
May 29, 2021
It is critical to have an exit button coded in the game so that one can walk out without turning off the computer and at times, mood.
This task can not get any simpler than this :)
However, please make sure that a game manager script is in place that takes care of shifting in between scenes of the game.
- In the update method, write an if statement which checks for the escape keypress.
- Unity has a special command that does the rest of the job.
- The scripting reference is here from Unity.
- Save the script and go back to the game to verify the exit part being taken care of :)
Thank you very much