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
In questa pagina del sito puoi guardare il video online How to EXIT GAME with BUTTON in Unity della durata di ore minuti seconda in buona qualità , che l'utente ha caricato GDT Solutions ES 19 marzo 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 42,342 volte e gli è piaciuto 487 spettatori. Buona visione!