Skip to main content

Lifecycle Events

Events a script binds to as the Lens runs: start, update, enable and disable, pause and resume, capture and recording, deep links, and delayed callbacks.

Commonly used

Guides

All APIs in this topic

Require modules with require('LensStudio:<name>') and create events with script.createEvent('<name>').

Components, assets, and modules

APIDescription
DeepLinkModule SPECSThe DeepLinkModule brings the concept of deep linking, familiar from mobile platforms like Android and iOS, to Spectacles.

Events

APIDescription
DelayedCallbackEventAn event that gets triggered after a delay.
LateUpdateEventEvent that runs during each frame, only if a Component and its SceneObject is enabled.
MessageEvent SPECSEvent fired when a message is received from the host (Lens Studio or an AI agent).
OnAwakeEventEvent that runs immediately when a Component is constructed or deserialized.
OnDestroyEventEvent that runs when a Component will be destroyed.
OnDidEnterForegroundEvent SPECSTriggered when the Lens has entered the Foreground phase.
OnDidEnterSuspendedEvent SPECSTriggered when the Lens has entered the Suspended phase.
OnDisableEventEvent that runs when a Component becomes disabled, either directly via its own Component.enabled property or because its SceneObject becomes disabled.
OnEnableEventEvent that runs when a Component becomes enabled, either directly via its own Component.enabled property or because its SceneObject becomes enabled.
OnFullScreenEnterEvent Camera KitTriggered immediately when the Lens enters full-screen mode.
OnFullScreenExitEvent Camera KitTriggered when the Lens returns to the standard UI with carousel and other Snapchat UI elements.
OnPauseEvent SPECSTriggered when users tap the menu button in Palm UI.
OnResumeEvent SPECSTriggered when users tap the menu button in Palm UI during pause state.
OnStartEventRuns on the first frame a Component is enabled, at a later point than OnAwakeEvent but guaranteed within the first frame before rendering.
OnTimeStartEventThe base class for scenewide events.
OnWillEnterForegroundEvent SPECSTriggered when the Lens is about to enter the Foreground phase.
OnWillEnterSuspendedEvent SPECSTriggered when the Lens is about to enter the Suspended phase.
SceneEventThe base class for scenewide events.
SceneObjectEventBase class for all object-based Event types in Lens Studio (ManipulateStartEvent, TapEvent, etc.).
SnapImageCaptureEventCalled when the user taps on the capture button to record an image.
SnapRecordStartEventGets called when the user starts long pressing the capture button to record a Snap.
SnapRecordStopEventGets called when the user stops long pressing the Snap button to end recording of a Snap.
TurnOffEventTriggered when the lens turns off.
UpdateEventEvent that runs during each frame, only if a Component and its SceneObject is enabled.

Event data

APIDescription
DeepLinkUriReceivedArgs SPECSArguments used with the DeepLinkModule#onUriReceived event.

Objects and data

APIDescription
EventRegistration
IEventParametersThe base class for parameter objects passed into event callbacks.

Enums

APIDescription
RecordingStateDescribes the current recording state of the Lens.
SceneActivityPhase SPECSRepresents the current lifecycle activity phase of the Scene.