Skip to main content

on_update

Function on_update 

Source
pub fn on_update(callback: impl Fn() + Send + Sync + 'static) -> Result<()>
Expand description

Runs callback once per frame on Unity’s main thread, a good place to update an overlay. Panics are caught and printed.

It works by hooking UnityEngine.Time.frameCount, which the engine reads every frame, and firing when the frame number changes. A frame where nothing reads Time.frameCount is skipped, which in an active game does not happen.