- Home /
End/Pause Game!
Can anyone tell me how to either, (or both) pause, or quit the game, with a button: This kind;
if (GUI.Button (Rect (20,40,80,20), "Menu")) {
Application.LoadLevel (0);
I just need the script and how to use it. Thanks!
Answer by qJake · Jul 13, 2010 at 08:23 PM
Make the button however you want, and put the quit/pause code inside it. For pause, read this:
http://answers.unity3d.com/questions/21/how-do-i-pause-my-game
(A quick Google search would have brought you there)
And for exiting the game to the desktop (doesn't work in the Editor or Webplayer), use this:
Application.Quit();
Answer by vincent121416 · Apr 22, 2016 at 12:34 PM
qJake's answer is the right one. But I have another tricky method. You can freeze the rigidbody.contraints of your player to stop the movement.
rigidbody.contraints is a bad idea becoz still transform.translate will work.