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.

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.

// @input Asset.Texture myTexture

const currentObj = script.sceneObject;
const imageComponent = currentObj.createComponent("Component.Image");
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("Component.Image");
const imageMaterial = imageComponent.mainPass;
imageMaterial.baseTex = this.myTexture;
}
}

Hierarchy (View Summary, Expand)

Constructors

Properties

name: string

The name of the Asset in Lens Studio.

uniqueIdentifier: string

Methods

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

    Parameters

    • type: string

    Returns boolean

MMNEPVFCICPMFPCPTTAAATR