- Home /
How to close the game using new UI
In my GUI screen I have Exit button. And I have a script:
void Start()
{
Application.Quit ();
}
But I can't understand, how to use this script in the new UI in the Button element. What kind of function should I choose in the On Click component?
When I choose my script (Exit.cs), it doesn't work.
Answer by KarlGG · Dec 15, 2014 at 08:17 PM
Instead of "Start" (which will run as soon as the object is instantiated) name your function something else, "ExitButton" or something. When you choose the script, it will ask you what function to use. Pick that one.
Also, remember that you can't quit while inside the Unity Editor, so you may want to print() or debug.log() to see that it runs when you click it.
Your answer
Follow this Question
Related Questions
Unity 2021 LTS: IPointerEnterHandler is broken 1 Answer
DropDown menu(add item from input field): Object reference not set to instance of an object C# 1 Answer
Cannot accessing text in InputField Array 1 Answer
Changing the target of a button that takes a gameobject as a parameter? 0 Answers
Setting negative value for rectTransform sizedelta !!! 0 Answers