Contents

subscribe(to:_:)

Subscribes to an action event.

Declaration

@MainActor @preconcurrency static func subscribe(to eventType: ActionEventType, _ handler: @escaping @MainActor (ActionEvent<Self>) -> Void)

Discussion

For example, you can call this method to subscribe to the update event, which the system calls each frame it evaluates the action:

struct MyAction: EntityAction {
    ...
}
MyAction.subscribe(to: .updated) { event in
    // RealityKit calls this closure in lock step as it
    // processes each animation frame.
}