BaseScriptComponent
ClassClass in the Lens Scripting API.
- Available on all platforms
TypeScript only
Index
Properties
Methods
Implements
ScriptComponent
Constructors
Constructor
new BaseScriptComponent():
BaseScriptComponent
Returns
BaseScriptComponent
Properties
enabled
enabled:
boolean
If disabled, the Component will stop enacting its behavior.
Default Value
true
Implementation of
ScriptComponent.enabled
isBeingDestroyed
isBeingDestroyed:
boolean
Returns true if this Component is currently being destroyed. Becomes true as soon as
destruction begins via Component#destroy or destruction of its owning SceneObject,
before any OnDestroyEvent callbacks fire.
Since
Lens Scripting Version 364
Example
if (!script.isBeingDestroyed) {
// Component is still fully alive
}
Implementation of
ScriptComponent.isBeingDestroyed
isEnabledInHierarchy
isEnabledInHierarchy:
boolean
Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.
Implementation of
ScriptComponent.isEnabledInHierarchy
name
name:
string
sceneObject
sceneObject:
SceneObject
The SceneObject this component is on.
Implementation of
ScriptComponent.sceneObject
uniqueIdentifier
uniqueIdentifier:
string
Since
Lens Scripting Version 176
Implementation of
ScriptComponent.uniqueIdentifier
updateOrder
readonlyupdateOrder:number
The relative execution order of this script's lifecycle callbacks
(onStart, onUpdate, onLateUpdate, etc.) among all scripts in the Lens.
Scripts with a smaller updateOrder run before scripts with a larger
updateOrder. Reflects the updateOrder set on the attached
ScriptAsset. Defaults to 0.
Remarks
updateOrder only orders scripts relative to each other; it
does not affect ordering relative to non-script engine Components.
Since
Lens Scripting Version 367
Example
if (script.updateOrder < 0) {
// This script runs before scripts at the default updateOrder.
}
Implementation of
ScriptComponent.updateOrder
updatePriority
updatePriority:
number
Methods
createEvent()
createEvent<
K>(eventType):EventNameMap[K]
Adds a new SceneEvent, triggered by eventType events, to the ScriptComponent.
Type Parameters
| Type Parameter |
|---|
K extends keyof EventNameMap |
Parameters
| Parameter | Type |
|---|---|
eventType | K |
Returns
EventNameMap[K]
Implementation of
ScriptComponent.createEvent
destroy()
destroy():
void
Destroys the component.
Returns
void
Implementation of
ScriptComponent.destroy
getReferencedEvents()
getReferencedEvents():
SceneEvent[]
Returns the list of SceneEvents referenced by this ScriptComponent.
Returns
SceneEvent[]
Since
Lens Scripting Version 354
Implementation of
ScriptComponent.getReferencedEvents
getSceneObject()
getSceneObject():
SceneObject
Returns the SceneObject the component is attached to.
Returns
SceneObject
Implementation of
ScriptComponent.getSceneObject
getTransform()
getTransform():
Transform
Returns the Transform this component is attached to.
Returns
Transform
Implementation of
ScriptComponent.getTransform
getTypeName()
staticgetTypeName<T>(this):TypeName<InstanceType<T>>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Type Parameters
| Type Parameter |
|---|
T extends typeof BaseScriptComponent |
Parameters
| Parameter | Type |
|---|---|
this | T |
Returns
TypeName<InstanceType<T>>
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Implementation of
ScriptComponent.getTypeName
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Implementation of
ScriptComponent.isOfType
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Implementation of
ScriptComponent.isSame
removeEvent()
removeEvent(
event):void
Removes a previously added SceneEvent from the ScriptComponent.
Parameters
| Parameter | Type |
|---|---|
event | SceneEvent |
Returns
void
Implementation of
ScriptComponent.removeEvent
requestPersistInput()
requestPersistInput(
inputName):void
Requests Lens Studio to persist the named @input into the project model.
Only has effect in the Scene Editor viewport.
Call after mutating the input from script when the change should persist. Will only persist if this ScriptComponent is still alive at the end of the frame.
Parameters
| Parameter | Type |
|---|---|
inputName | string |
Returns
void
Since
Lens Scripting Version 378
Example
script.topLeft = handle.getTransform().getLocalPosition();
script.requestPersistInput("topLeft");
Implementation of
ScriptComponent.requestPersistInput