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
На этой странице сайта вы можете посмотреть видео онлайн How to EXIT GAME with BUTTON in Unity длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь GDT Solutions ES 19 Март 2020, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 42,342 раз и оно понравилось 487 зрителям. Приятного просмотра!