Pause Game With Multiple Scripts?

Hello,

I am trying to pause my game, but when I call my pause function and set Time.timeScale = 0, only 1 script pauses.

Is there a way to have a universal pause script that tells the whole program to pause once a button is pushed?

“Is there a way to have a universal pause script that tells the whole program to pause once a button is pushed”

Yes! It’s called good design practices! Typically games employ a “game state manager” - often a singleton - which drives core application logic like pausing, running, returning to menus, etc. If you create a game state manager singleton, your scripts can use logic such as:

if (GSM.Instance.isPaused) return;  

Throw that at the top of a script’s Update loop and presto~ pausing prevents execution below that line.

Setting Time.timescale to zero does not prevent Update() methods from running. This is a very good thing, but it means you have to take explicit control over which scripts can run while paused.

Without these extra steps, setting timescale to zero will only “pause” things whose logic is driven by the passage of time, such as coroutines, physics, particles, and any object whose properties are driven by scaled time or deltaTime.