How to EXIT GAME with BUTTON in Unity

Publié le: 19 mars 2020
sur la chaîne: GDT Solutions ES
42,342
487

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


Sur cette page du site, vous pouvez voir la vidéo en ligne How to EXIT GAME with BUTTON in Unity durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur GDT Solutions ES 19 mars 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 42,342 fois et il a aimé 487 téléspectateurs. Bon visionnage!