In this Video we see the instruction we need to execute in order to close a Unity game.
We're gonna setup a simple scene with a button to test this function.
By default we can quit the game in Unity using Alt+F4, but in this case we want to close the game programmatically.
Instruction to close a Unity game:
Application.Quit();
How to exit the game with a button in Unity:
1. Create a Button in the Canvas
2. Create a Script to exit the game or use an existing one, define inside a public function for the button to execute it (example below).
3. Create an OnClick Event in the Button component, assign the GameObject who has the Script where the Exit function is defined and select that function from the list.
Example function to exit the game:
public void ExitGame(){
Application.Quit();
}
____________________________________________________________
LINKS
Portfolio: https://gamedevtraum.com/en/portfolio...
LinkedIn: / gamedevtraum
Downloads: https://gamedevtraum.itch.io/
Contact: / gamedevtraum
____________________________________________________________
#EN
On this page of the site you can watch the video online How to EXIT GAME with BUTTON in Unity with a duration of hours minute second in good quality, which was uploaded by the user GDT Solutions ES 19 March 2020, share the link with friends and acquaintances, this video has already been watched 42,342 times on youtube and it was liked by 487 viewers. Enjoy your viewing!