Might need PauseUpdate()
When the timer is paused, I find that it is hard to resume the timer by itself.
For example, when the game is paused, all timers could detect this in their Action<float> OnUpdate and they are paused automatically. However, when the game is resumed, it is hard to let the timer know this by itself so that it could resume by itself.
Hey, thanks for opening this, and sorry for the slow response! This is an interesting problem.
I think it would be painful for you to have to write logic in every Timer that checks for whether your game is paused or not. There are a couple of ways that you might be able to handle pausing using the existing API:
- On your pause screen, you can set Time.timeScale to
0. By default all timers use game time (when not settinguseRealTime: true) so setting it to zero will stop the timers.
This won't work for you if you're using game time for effects on your pause screen.
- If that approach doesn't work for you, there are existing
Timer.PauseAllRegisteredTimers/Timer.ResumeAllRegisteredTimersfunctions that should work. However any new timers that are created by logic on your pause screen won't be caught by this. We might deprecate those functions and add EnableManager/DisableManager functions instead that would turn off all timer updating logic completely. Let us know if that would be useful for you.