Skip to main content

on_render

Function on_render 

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

Runs callback on the render thread after each camera finishes rendering, passing the Camera. This is where to draw an overlay on top of the game with gl, or to drive an immediate-mode UI such as egui.

It hooks Camera.FireOnPostRender, which Unity invokes from native code per camera render, so the callback runs in the render pipeline whether or not anything subscribed to Camera.onPostRender. Games with several cameras call it more than once per frame; compare the passed camera’s name() if you only want one. Panics are caught and printed.