How to EXIT GAME with BUTTON in Unity

Veröffentlicht am: 19 März 2020
auf dem Kanal: 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


Auf dieser Seite können Sie das Online-Video How to EXIT GAME with BUTTON in Unity mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer GDT Solutions ES 19 März 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 42,342 Mal angesehen und es wurde von 487 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!