Skip to main content

Asset

Class

Base class for all assets used in the engine.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Base class for all assets used in the engine. Assets can be unique to Lens Studio, such as VFXAsset, or a representation of an imported asset, such as Texture for jpg, png, and other image formats. In most cases, assets are added to the scene via a Component.

Index

Remarks

For example, you might import an .jpg file into your project to be used in the Lens by dragging your file into the Asset Browser panel, which will create a Texture asset. Then, in the Scene Hierarchy panel, you can add a SceneObject containing the Image component (Scene Hierarchy panel > + > Image), and set the Texture field of the Image component to the newly imported asset in the Inspector panel.

Example

// @input Asset.Texture myTexture

const currentObj = script.sceneObject;
const imageComponent = currentObj.createComponent(Image.getTypeName());
const imageMaterial = imageComponent.mainPass;
imageMaterial.baseTex = script.myTexture;
@component
export class AssetExample extends BaseScriptComponent {
@input()
myTexture: Texture;

onAwake() {
const currentObj = this.sceneObject
const imageComponent = currentObj.createComponent(Image.getTypeName());
const imageMaterial = imageComponent.mainPass;
imageMaterial.baseTex = this.myTexture;
}
}

Extends

Extended by

Properties

name

name: string

The name of the Asset in Lens Studio.

Default Value

""

uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

SerializableWithUID.uniqueIdentifier

Methods

getTypeName()

static getTypeName(): TypeName<Asset>

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().

Returns

TypeName<Asset>

Overrides

SerializableWithUID.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

SerializableWithUID.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

SerializableWithUID.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

ParameterType
otherScriptObject

Returns

boolean

Inherited from

SerializableWithUID.isSame

See also