TouchComponent
Lens Studio v1.0.0+
Scripting Name: Component.TouchComponent
Inherits from Component
Description
Allows the MeshVisual
provided to this component to handle touches on the screen (blocking Snapchat from receiving the touches), and optionally let certain touch types to pass through (let Snapchat handle the touch).
Possible TouchType
values:
- “TouchTypeNone”
- “TouchTypeTouch”
- “TouchTypeTap”
- “TouchTypeDoubleTap”
- “TouchTypeScale”
- “TouchTypePan”
- “TouchTypeSwipe”
Methods
addMeshVisual(BaseMeshVisual meshVisual)
: void
Adds a MeshVisual
as a target for touch detection.
addTouchBlockingException(String exception)
: void
Adds a touch type that this component will ignore.
getMinimumTouchSize()
: Number
Returns the minimum bounding box size used for detecting touches. Value range is from 0-1, relative to screen width.
removeMeshVisual(BaseMeshVisual meshVisual)
: void
Removes a MeshVisual
as a target for touch detection.
setCamera(Camera cameraValue)
: void
Sets the camera that will be used for touch detection.
setMinimumTouchSize(Number minimumSize)
: void
Sets the minimum bounding box size used for detecting touches. Value range is from 0-1, relative to screen width.
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
// Pass in a MeshVisual
// @input Component.MeshVisual myMeshVisual
// Get a reference to the TouchComponent
var touchComponent = script.getFirstComponent("Component.TouchComponent");
// Sets the MeshVisual to handle touches
touchComponent.addMeshVisual(script.myMeshVisual);
// Allow certain touch types to be passed to Snapchat
touchComponent.addTouchBlockingException("TouchTypeDoubleTap");
Still Looking for help?
Visit Support