Generic Instance Method

subscribe(to:on:_:)

Receives events of the given type.

Declaration

func subscribe<E>(to event: E.Type, on sourceObject: EventSource? = nil, _ handler: @escaping (E) -> Void) -> Cancellable where E : Event

Parameters

event

The type of the event, like SceneEvents.Update.Self.

sourceObject

The source of the event. Set to nil to listen for all events of the given type within the scene.

handler

A closure to call with the event.

Return Value

The subscription to the event stream.

See Also

Getting and Sending Events

func publisher<E>(for: E.Type, on: EventSource?) -> Scene.Publisher<E>

Generates a publisher for events of the specified type.

struct Scene.Publisher

A publisher for the given event type in the scene.

enum SceneEvents

Events the scene triggers.

enum AnimationEvents

Events triggered by the RealityKit animation system.

enum AudioEvents

Events associated with audio playback.

enum CollisionEvents

Events associated with collisions.

protocol Event

A type that can be sent as an event.

protocol EventSource

A type on which events can be published and subscribed.