Preparing search index...

    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)

    Index

    Properties

    basisResolution: vec2

    The virtual resolution used when Canvas.offsetUnit is set to Pixels. Child ScreenTransform offset values are scaled by (Canvas size / basisResolution). For example, a basisResolution of (1080, 1440) on a 30x40 cm Canvas means an offset of 100 equals approximately 2.78 cm horizontally (100 / 1080 * 30). Setting this property will auto-adjust all descendant ScreenTransform offsets to preserve their visual positions. Has no effect when Canvas.offsetUnit is World.

    (1080, 1920)
    
    debugRenderLayoutRect: boolean

    If enabled, draws the Canvas#layoutRect bounds as a wireframe for debugging Canvas layout.

    Lens Scripting Version 364

    false
    
    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    true
    
    isBeingDestroyed: boolean

    Returns true if this Component is currently being destroyed. Becomes true as soon as destruction begins via Component#destroy or destruction of its owning SceneObject, before any OnDestroyEvent callbacks fire.

    Lens Scripting Version 364

    if (!script.isBeingDestroyed) {
    // Component is still fully alive
    }
    isEnabledInHierarchy: boolean

    Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.

    layoutRect: Rect

    The rectangular bounds that define the area child objects are laid out within. Each bound is defined as an offset in world units from the SceneObject's position.

    Lens Scripting Version 364

    offsetScale: vec2

    The scale applied to child ScreenTransform offsets when Canvas.offsetUnit is Pixels (Canvas size / Canvas.basisResolution); returns (1, 1) for World offset units or when resolution is invalid.

    offsetUnit: OffsetUnit

    Controls whether child ScreenTransform offsets are in world units or virtual pixels. When set to Pixels, offsets are scaled by the Canvas size divided by Canvas.basisResolution. When set to World (default), offsets are in world units regardless of the basisResolution value. Setting this property will auto-adjust all descendant ScreenTransform offsets to preserve their visual positions.

    Canvas.OffsetUnit.World
    
    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.

    Lens Scripting Version 182

    (0, 0)
    
    sceneObject: SceneObject

    The SceneObject this component is on.

    sortingType: SortingType

    The rendering sort order for the objects underneath this canvas.

    Lens Scripting Version 234

    Canvas.SortingType.Hierarchy
    
    uniqueIdentifier: string

    Lens Scripting Version 176

    unitType: UnitType

    The unit for the objects underneath this canvas.

    Lens Scripting Version 234

    Canvas.UnitType.World
    
    worldSpaceRect: Rect

    Use Canvas#layoutRect instead.

    Lens Scripting Version 364

    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