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
OnStartEventRuns on the first frame a Component is enabled, at a later point than OnAwakeEvent but guaranteed within the first frame before rendering.UpdateEventEvent that runs during each frame, only if a Component and its SceneObject is enabled.DelayedCallbackEventAn event that gets triggered after a delay.LateUpdateEventEvent that runs during each frame, only if a Component and its SceneObject is enabled.OnAwakeEventEvent that runs immediately when a Component is constructed or deserialized.OnDestroyEventEvent that runs when a Component will be destroyed.
Guides
Script EventsThis guide provides a breakdown of Lens Events available.Accessing ComponentsScript Components in Lens Studio are able to reference one another whether they have been created with JavaScript, TypeScript or Custom Component.Custom NodesCustom nodes can be written just like normal scripts in Lens Studio, with some small differences.In-Viewport AuthoringCreate interactive Scene Editor handles with @runInEditor, persist @input values, and omit viewport-only assets from the packed Lens.Scripting ExampleThis guide will walk you through the process of creating a basic script in Lens Studio.Touch and InteractionsYou can add interactivity to the Lenses you create in Lens Studio by handling user touch input events.
All APIs in this topic
Require modules with require('LensStudio:<name>') and create events with script.createEvent('<name>').
Components, assets, and modules
| API | Description |
|---|---|
| DeepLinkModule SPECS | The DeepLinkModule brings the concept of deep linking, familiar from mobile platforms like Android and iOS, to Spectacles. |
Events
| API | Description |
|---|---|
| DelayedCallbackEvent | An event that gets triggered after a delay. |
| LateUpdateEvent | Event that runs during each frame, only if a Component and its SceneObject is enabled. |
| MessageEvent SPECS | Event fired when a message is received from the host (Lens Studio or an AI agent). |
| OnAwakeEvent | Event that runs immediately when a Component is constructed or deserialized. |
| OnDestroyEvent | Event that runs when a Component will be destroyed. |
| OnDidEnterForegroundEvent SPECS | Triggered when the Lens has entered the Foreground phase. |
| OnDidEnterSuspendedEvent SPECS | Triggered when the Lens has entered the Suspended phase. |
| OnDisableEvent | Event that runs when a Component becomes disabled, either directly via its own Component.enabled property or because its SceneObject becomes disabled. |
| OnEnableEvent | Event that runs when a Component becomes enabled, either directly via its own Component.enabled property or because its SceneObject becomes enabled. |
| OnFullScreenEnterEvent Camera Kit | Triggered immediately when the Lens enters full-screen mode. |
| OnFullScreenExitEvent Camera Kit | Triggered when the Lens returns to the standard UI with carousel and other Snapchat UI elements. |
| OnPauseEvent SPECS | Triggered when users tap the menu button in Palm UI. |
| OnResumeEvent SPECS | Triggered when users tap the menu button in Palm UI during pause state. |
| OnStartEvent | Runs on the first frame a Component is enabled, at a later point than OnAwakeEvent but guaranteed within the first frame before rendering. |
| OnTimeStartEvent | The base class for scenewide events. |
| OnWillEnterForegroundEvent SPECS | Triggered when the Lens is about to enter the Foreground phase. |
| OnWillEnterSuspendedEvent SPECS | Triggered when the Lens is about to enter the Suspended phase. |
| SceneEvent | The base class for scenewide events. |
| SceneObjectEvent | Base class for all object-based Event types in Lens Studio (ManipulateStartEvent, TapEvent, etc.). |
| SnapImageCaptureEvent | Called when the user taps on the capture button to record an image. |
| SnapRecordStartEvent | Gets called when the user starts long pressing the capture button to record a Snap. |
| SnapRecordStopEvent | Gets called when the user stops long pressing the Snap button to end recording of a Snap. |
| TurnOffEvent | Triggered when the lens turns off. |
| UpdateEvent | Event that runs during each frame, only if a Component and its SceneObject is enabled. |
Event data
| API | Description |
|---|---|
| DeepLinkUriReceivedArgs SPECS | Arguments used with the DeepLinkModule#onUriReceived event. |
Objects and data
| API | Description |
|---|---|
| EventRegistration | |
| IEventParameters | The base class for parameter objects passed into event callbacks. |
Enums
| API | Description |
|---|---|
| RecordingState | Describes the current recording state of the Lens. |
| SceneActivityPhase SPECS | Represents the current lifecycle activity phase of the Scene. |