Refer to post title
(I need a GUI button to pause the game)
Refer to post title
(I need a GUI button to pause the game)
Have a GUI button that changes the timescale to 0
Here’s a little script I found in another thread that should work nicely.
function Update () {
if (Input.GetKeyDown("p")) {
if (Time.timeScale == 0.0) Time.timeScale = 1.0;
else Time.timeScale = 0.0;
}
}
You just need to change the “if (input…)” part to be whatever you’re using for your pause button.
There can be some surprisingly tricky details when trying to pause a game. Merely setting time scale to 0.0 helps, but isn’t all. Google/Search the forum for paused game and you’ll find some threads on the subject. Pausing sounds mid-play, and other issues have to be dealt with along side the question “do you really want to freeze everything?” Function Update continues to work and so does several of the real time functions, so you can make your on deltaRealTime …