A 2D canvas anchored in 3D space that acts as the root of the ScreenTransform hierarchy. ScreenTransform SceneObjects 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;
interface Canvas {
    enabled: boolean;
    pivot: vec2;
    sceneObject: SceneObject;
    sortingType: Canvas.SortingType;
    uniqueIdentifier: string;
    unitType: Canvas.UnitType;
    worldSpaceRect: Rect;
    destroy(): void;
    getSceneObject(): SceneObject;
    getSize(): vec2;
    getTransform(): Transform;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
    setSize(value: vec2): void;
}

Hierarchy (view full)

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
sortingType: Canvas.SortingType
uniqueIdentifier: string
unitType: Canvas.UnitType
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