Quit Button

Hello,

I have made a Button. Creat → UI → Button.

I want that Button to quit the game when pressed.
How do i script that?

Thank you.

Make a function as public like this attach it to game object add listener for that button and call this function

public void Quit()
{
     Application.Quit();
}

I came here looking for the same answer. Except, I found that Application.Quit only works in built games. I don’t want to build the game to test it. I’ve used scripts before in classes (created by someone else) that can quit the game in editor. How would I accomplish this?