Lens Scripting API

    Class Canvas

    A root of the 2D ScreenTransform hierarchy in 3D space. Also used to configure unit settings of Orthographic Camera.

    SceneObjects with ScreenTransform can be placed on the Canvas, and the Canvas can be sized and placed anywhere in 3D space. It is like a painter’s canvas for ScreenTransforms.

    var canvas = script.getSceneObject().getComponent("Component.Canvas");
    print(canvas.pivot); // Outputs: {x: 0, y: 0}

    // Note: this variable will be a COPY of canvas.pivot, not reference
    var pivotCopy = canvas.pivot;

    // Can mutate the copy then set it again
    pivotCopy.x = 1;
    pivotCopy.y = 1;

    canvas.pivot = pivotCopy;

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    Properties

    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    pivot: vec2

    The point about which the Canvas Rectangle will rotate. Defined as fractional coordinates of the Canvas's dimensions. e.g. (1 , 1) brings the pivot to the top right corner of the canvas. Or (0.5, 0) moves the pivot to the right by half the canvas width.

    sceneObject: SceneObject

    The scene object this component is on.

    sortingType: SortingType

    The rendering sort order for the objects underneath this canvas.

    uniqueIdentifier: string
    unitType: UnitType

    The unit for the objects underneath this canvas.

    worldSpaceRect: Rect

    World Space Rectangle that defines the Canvas as offsets in world units from the SceneObject's position

    Methods

    • Destroys the component.

      Returns void

    • Get size of rectangle as (width, height)

      Returns vec2

    • Returns the name of this object's type.

      Returns string

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

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Set size of rectangle as (width, height)

      Parameters

      Returns void

    MMNEPVFCICPMFPCPTTAAATR