How to quit a PC or Mac game stand alone player

This is probably a dumb question but I’ve been using the webplayer to publish Unity projects and not the standalone PC/Mac installers.

How do you quit the stand alone players? They run just like the web demo except for the fact that I can’t quit and have to force restart the computer to get out of them: Mac and PC versions.

I’m doing something wrong but don’t see what from the docs. It’s probably one of those really obvious things.

Thanks.

Make a quit button, or use the same keyboard command you use for all other apps (Command-Q on Mac, something else on Windows that I can’t remember–you can see it in the menu if you run in non-fullscreen mode).

–Eric

OK, I’ve not done much, (well anything) with the GUI which I guess is where the quit button would be.

I didn’t try command Q from memory, just escape etc. I’ll try running in not full screen to check.

Thanks very much Eric.

The simplest thing is to make a GUITexture with a quit button texture, and put this script on it:

function OnMouseUp() {
   Application.Quit();
}

If you want escape to quit, then add this:

function Update() {
   if (Input.GetKeyDown("escape")) Application.Quit();
}

–Eric

You are a star!

I shall try that tomorrow.

Thanks!

Alt-F4

May I be burned at the stake for using this one on a (week)daily basis. :evil:

Doesn’t work.
There must be more to the script.

Works fine when applicable, and there isn’t more to the script. See the docs for when it’s ignored.

–Eric

Guess I have to figure out when it’s applicable then. Thanks anyway, I’ll keep working on it.

Application.Quit is explained quite clearly in the docs; you don’t actually have to figure out anything.

–Eric

If you are running it in the editor it won’t quit your application but it will when you do a stand-alone build.

Ah ha! I’ll try again! Thank you!

Just getting a bunch of errors from the console

You couldn’t be kind enough to post a link could you?
Cheers

OK here’s the thing that works for me:

function OnGUI () {
if (GUI.Button (Rect (25, 25, 100, 30), “Quit”)) {
Application.Quit();
}
}

Thanks everybody!