Preparing search index...

    Manages 2D canvas rendering and layout properties for a scene object.

        const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
    const scene = model.project.scene;

    // Canvas is the root for ScreenTransform-based UI layouts. It's most
    // commonly used for 2D HUD/UI, but it also works in 3D space — drop it
    // on any SceneObject and its children with ScreenTransform render in
    // local 2D coordinates. SortingType.Hierarchy draws children in scene
    // tree order, which is handy for stacked panels placed in 3D.
    // See: https://developers.snap.com/lens-studio/lens-studio-workflow/scene-set-up/2d/canvas-component
    const obj = scene.createSceneObject('UICanvas');
    const canvas = obj.addComponent('Canvas') as Editor.Components.Canvas;

    canvas.unitType = Editor.Components.UnitType.Pixels;
    canvas.sortingType = Editor.Components.SortingType.Hierarchy;
    canvas.pivot = new vec2(0.5, 0.5);
    console.log(`Canvas: unitType=${canvas.unitType}, sorting=${canvas.sortingType}`);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    enabled: boolean

    Whether the component is active.

    id: Uuid

    The unique id of the entity.

    meta: Meta

    Metadata associated with this entity, providing access to its unique identifier and other descriptive properties.

    name: string

    Name of the component.

    pivot: vec2

    Anchor point for the canvas as a normalized 2D vector.

    sceneObject: SceneObject

    Scene object this component is attached to.

    sortingType: SortingType

    Determines how the canvas sorts its children during rendering.

    type: string

    The entity's type.

    unitType: UnitType

    Specifies the unit system used for canvas measurements.

    worldSpaceRect: Editor.Rect

    Bounding rectangle of the canvas in world space coordinates.

    Methods

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean