Scripting
Writing scripts and wiring them into the scene: script components, decorators, script assets, require, and the script globals.
Commonly used
BaseScriptComponentTypeScript onlyScriptComponentUsed to bind custom JavaScript or TypeScript code to specific Lens events for dynamic interactivity.globalisNullReturns true if the passed in object is null or destroyed.requireLoad a JavaScript module.requireAssetLoad an asset like a Texture, Material, or MLAsset directly from script.
Guides
In-Viewport AuthoringCreate interactive Scene Editor handles with @runInEditor, persist @input values, and omit viewport-only assets from the packed Lens.Accessing ComponentsScript Components in Lens Studio are able to reference one another whether they have been created with JavaScript, TypeScript or Custom Component.Script ComponentsIn Lens Studio, scripts are added to the scene as Script Components, which are attached to Scene Objects.Script ModulesScript Modules allow you to encapsulate code to use throughout your project.Custom Script UICustom UI can be used to control how your script input fields appear in the Inspector panel.Script EventsThis guide provides a breakdown of Lens Events available.
All APIs in this topic
Add components to a scene object and reference assets and other modules with a script input.
Components, assets, and modules
| API | Description |
|---|---|
| EditorInteractionProfile | Declares how stock Scene Editor Move / Rotate / Scale manipulators may interact with a SceneObject. |
| NativeLibraryAsset SPECS | NativeLibraryAsset loads a native shared library (e.g. .so, .dylib, .dll) and exposes its exports to JavaScript. |
| ScriptAsset | Represents a JavaScript or TypeScript script that can be used to add logic in your Lens. |
| ScriptComponent | Used to bind custom JavaScript or TypeScript code to specific Lens events for dynamic interactivity. |
Objects and data
| API | Description |
|---|---|
| BaseScriptComponent TypeScript only | |
| Decorators TypeScript only | The Decorators typings for TypeScript Lens scripts. |
| global | |
| isNull | Returns true if the passed in object is null or destroyed. |
| require | Load a JavaScript module. |
| requireAsset | Load an asset like a Texture, Material, or MLAsset directly from script. |
| requireType | Load a script by name or path in order to use that type to create or get a component at runtime. |
| script | |
| UIControl TypeScript only |
Related topics
InteractionTouch, tap, gestures and manipulation, SPECS hand gestures (Gesture Module), keyboard and text input, controllers, and haptics.Cloud, Networking & Storage › StorageData kept on the device between sessions, and cloud storage shared across users or locations.Text & Fonts2D and 3D text, fonts, text styling, and localization.