UpdateManager¶
Centralized, zero-allocation manager for ticking updates, delays, and frame intervals without coroutines.
Namespace: Jungle.Utils
Inherits: MonoBehaviour
Overview¶
UpdateManager is a singleton that replaces per-object Update(), FixedUpdate(), and LateUpdate() calls with a single centralized loop. It also provides time-based delays, frame-based delays, and repeating timers -- all without coroutines or per-frame allocations.
The instance is created automatically via DontDestroyOnLoad the first time it is accessed. It uses O(1) swap-removal internally to avoid garbage from list compaction.
Static Methods¶
| Method | Description |
|---|---|
RegisterUpdate(IUpdatable) |
Subscribes to the Update loop. |
UnregisterUpdate(IUpdatable) |
Removes from the Update loop. |
RegisterFixedUpdate(IFixedUpdatable) |
Subscribes to the FixedUpdate loop. |
UnregisterFixedUpdate(IFixedUpdatable) |
Removes from the FixedUpdate loop. |
RegisterLateUpdate(ILateUpdatable) |
Subscribes to the LateUpdate loop. |
UnregisterLateUpdate(ILateUpdatable) |
Removes from the LateUpdate loop. |
RegisterDelay(float, IDelayedTarget, bool, JungleUpdateLoop) |
Fires after a time delay. Returns UpdateTaskId. |
RegisterDelay(float, Action, bool, JungleUpdateLoop) |
Fires a callback after a time delay. |
RegisterRepeated(float, IDelayedTarget, bool, JungleUpdateLoop) |
Fires repeatedly at a time interval. |
RegisterFrames(int, IFrameTarget, JungleUpdateLoop) |
Fires after N frames. |
RegisterRepeatedFrames(int, Action, JungleUpdateLoop) |
Fires every N frames. |
CancelTask(UpdateTaskId) |
Cancels a previously registered delay or frame task. |
Interfaces¶
Implement these on your class and register with the corresponding method:
IUpdatable--void OnUpdate(float deltaTime)IFixedUpdatable--void OnFixedUpdate(float fixedDeltaTime)ILateUpdatable--void OnLateUpdate(float deltaTime)IDelayedTarget--void OnDelayCompleted()IFrameTarget--void OnFrameReached()