Skip to content
On this page

Class: UICanvas

WebSG.UICanvas

A UICanvas is used to render UI elements to a flat plane in the world.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new UICanvas()

Properties

size

Readonly size: Vector2

Gets the canvas size as a Vector2 in meters.

Defined in

websg.d.ts:1259

Accessors

height

get height(): number

Gets the canvas height in pixels.

Returns

number

Defined in

websg.d.ts:1242

set height(value): void

Sets the canvas height in pixels.

Parameters

NameTypeDescription
valuenumberThe canvas height in pixels.

Returns

void

Defined in

websg.d.ts:1248


root

get root(): undefined | UIElement

Gets the root UIElement of the canvas.

Returns

undefined | UIElement

Defined in

websg.d.ts:1220

set root(element): void

Sets the root UIElement of the canvas.

Parameters

NameTypeDescription
elementundefined | UIElementThe root UIElement of the canvas.

Returns

void

Defined in

websg.d.ts:1226


width

get width(): number

Gets the canvas width in pixels.

Returns

number

Defined in

websg.d.ts:1231

set width(value): void

Sets the canvas width in pixels.

Parameters

NameTypeDescription
valuenumberThe canvas width in pixels.

Returns

void

Defined in

websg.d.ts:1237

Methods

redraw

redraw(): undefined

Redraws the canvas. This should be called any time the UI elements are changed.

Returns

undefined

Defined in

websg.d.ts:1254