TimeManager
Overview
Owns pause / play / fast-forward controls and the authoritative tickTime. Exposes events to enable/disable the time UI, supports a force play flow (clears stacks), and keeps button visuals in sync. Maintains pause and disable stacks so multiple systems can request control without fighting.
Serialized Atoms & Events
FloatVariable tickTime,BoolVariable pausedVoidEvent enableTimeControls,VoidEvent disableTimeControls,VoidEvent forcePlayFloatEvent changeEventMusicParameter(set to 0 on resume to normalize music state)
Gameplay Settings
slowTime = 0.8f,normalTime = 0.4f,fastTime = 0.2f(tick durations)
UI
Button pauseButton,Button playButton,Button fastButtonColor selectedColor,selectedPauseColor,unselectedColor
Behavior
- Awake():
- Register to events and
paused.Changed. - Start paused (
paused = true) and select the Pause button.
- Register to events and
- EnableTimeControls():
- Decrement disable stack; when zero, enable buttons and re-select the last player choice (default Play).
- DisableTimeControls():
- Increment disable stack, disable play/fast buttons, select Pause.
- SetTimeNormal()/SetTimeFast():
- Set
tickTimeandpaused=false, select the corresponding button, remember user choice.
- Set
- Pause():
- Set
paused=true, select Pause.
- Set
- ForcePlay():
- Prime stacks, call
EnableTimeControls(), setpaused=false.
- Prime stacks, call
- OnPauseChanged(pausing):
- Maintains a pause stack; if any system still holds pause, re-assert pause.
- On resume (stack cleared), raises
changeEventMusicParameter(0).
Visuals
SelectButton(Button) updates ColorBlock.normalColor for selected/unselected buttons using the configured colors.