Usage.TimeUpdate Events - JuDelCo/Core GitHub Wiki
Namespace: Ju.Time
Time Update Events
In order to provide callbacks of the most common loop events (update, fixed update, etc) and for some other advanced ones, there are multiple events that can be used to run code at a specific time in the loop of your application.
All these events have a float property called DeltaTime
with the delta time between the last event fired of that type.
Usage
Read the EventBus service API to see how to subscribe to events.
Normal update (per frame) order of execution:
PreUpdate > Update > Unity Update > PostUpdate > Unity LateUpdate
Fixed update (per physics tick) order of execution:
PreFixedUpdate > FixedUpdate > Unity FixedUpdate > PreCollisionUpdate > Unity OnTrigger* > Unity OnCollision* > PostCollisionUpdate > PostFixedUpdate
TimePreUpdateEvent
It will be called before the TimeUpdateEvent
. Useful for early logic that you need to ensure that will be run before the Update.
TimeUpdateEvent
The most common event. Useful for any code that needs to be run every tick of your application.
TimePostUpdateEvent
It will be called after the TimeUpdateEvent
. Useful for late logic that you need to ensure that will be run after the Update.
In Unity, this is equivalent to LateUpdate
in MonoBehaviours.
TimePreFixedUpdateEvent
It will be called before the TimeFixedUpdateEvent
. Useful for early logic that you need to ensure that will be run before the FixedUpdate.
TimeFixedUpdateEvent
The second most common event. Useful for any code that needs to be run every tick with the same frequency. Heavy code that doesn't need to run every frame like physics or pathfinding usually goes here.
TimePreCollisionUpdateEvent
It will be called just after the TimeFixedUpdateEvent
and before the TimePostCollisionUpdateEvent
. Useful for logic that needs to be run after the FixedUpdate logic but just before the OnCollision and OnTrigger events.
TimePostCollisionUpdateEvent
It will be called after the TimePreCollisionUpdateEvent
and before the TimePostFixedUpdateEvent
. Useful for late logic that you need to ensure that will be run after the OnCollision and OnTrigger events but before the PostFixedUpdate event.
TimePostFixedUpdateEvent
It will be called after the TimeFixedUpdateEvent
. Useful for late logic that you need to ensure that will be run after the FixedUpdate, PreCollision and PostCollision events.