Subscribe to App Update Event#

If you would like to execute code for every update loop, you can can subscribe to app update events. By providing a callback function, Kit will execute your callback on every update loop. The event payload has a dt key that represents the time since the last loop. (i.e. delta time)

Warning

This event fires very frequently. A callback with long-running code will block the UI and make the app unresponsive.

import carb.events
import omni.kit.app


update_stream = omni.kit.app.get_app().get_update_event_stream()

def on_update(e: carb.events.IEvent):
    print(f"Update: {e.payload['dt']}")

sub = update_stream.create_subscription_to_pop(on_update, name="My Subscription Name")