ScriptComponent
Lens Studio v1.0.0+
Scripting Name: Component.ScriptComponent
Inherits from Component
Description
Binds scripts to Events and executes them when triggered. Any script can access the ScriptComponent executing them through the variable script
. See also: Scripting Overview, Script Events Guide.
Methods
createEvent(String eventType)
: SceneEvent
Adds a new SceneEvent, triggered by eventType
events, to the ScriptComponent.
removeEvent(SceneEvent event)
: void
Removes a previously added SceneEvent from the ScriptComponent.
Properties
api
: Object
Generic object accessible by other instances of ScriptComponent. Use this object to store references to properties and methods that need to be accessible from other ScriptComponents.
Inherited Methods
destroy()
: void
Destroys the component.
getSceneObject()
: SceneObject
Returns the SceneObject the component is attached to.
getTransform()
: Transform
Returns the Transform this component is attached to.
isSame(SerializableWithUID other)
: Boolean
Returns true if this object is the same as other
. Useful for checking if two references point to the same thing.
getTypeName()
: String
Returns the name of this object’s type.
isOfType(String type)
: Boolean
Returns true if the object matches or derives from the passed in type.
Inherited Properties
enabled
: Boolean
If disabled, the Component will stop enacting its behavior.
Examples
// Bind a function to the MouthOpened event
function onMouthOpen(eventData)
{
print("mouth was opened");
}
var event = script.createEvent("MouthOpenedEvent");
event.bind(onMouthOpen);
Still Looking for help?
Visit Support