UICanvas

Enumerations

RenderMode
Values:
  • ScreenSpaceOverlay = 0 - Render canvas as overlay

  • ScreenSpaceCamera = 1 - Render ui elements in screen space, but performing depth test against the 3D scene(WIP)

  • WorldSpace = 2 - Render ui elements in world space(WIP)

ScreenMode

Define the mode used to scale the canvas when the screen size changes.

Values:
  • Custom = 0 - Canvas size and scale completely controlled by the user.

  • Fit = 1 - Scale canvas to fit the screen and keep aspect ratio.

  • FitExtend = 2 - Scale canvas to fit the smallest screen dimension and another dimension is extended to fill the screen. Don’t keep aspect ratio. Default mode.

  • Fullscreen = 3 - Canvas size is set to the screen size. Don’t scale canvas and don’t keep aspect ratio.

Classes

UICanvas : NativeComponent

Note

UIFrame component is automatically added to the node if it is not already present

This component is used to enable rendering of UI children.

Example:

let canvas = create_node(NodeData())
add_component(canvas, new UICanvas())

let textNode = create_node(NodeData(
    parent = canvas,
    position = float3(0.0, 0.0, 0.0)
))
add_component(textNode, new UIText(
    text = "Hello, World!",
    fontSize = 48.0
))

let imageNode = create_node(NodeData(
    parent = canvas,
    position = float3(0.0, 200.0, 0.0)
))
add_component(imageNode, new UIImage(
    textureId = request_texture("image.png"),
    size = float2(300., 300.)
))

// Need any camera for UI to be seen
add_component(create_node(NodeData()), new Camera())
Fields:
  • initialSize : float2 = float2(-1f,-1f) - Initial size of the canvas. Automatically calculated from the size of the canvas. Will be used to calculate aspect ratio.

UICanvas.on_initialize()
UICanvas.on_destroy()
Properties:

UICanvas.renderMode: RenderMode
UICanvas.renderMode =(value: RenderMode)

The render mode of the canvas. Default is ScreenSpaceOverlay

Arguments:
UICanvas.localPosition2D: float2
UICanvas.localPosition2D =(value: float2)

Local position of the canvas. Default is (0, 0).

Arguments:
  • value : float2

UICanvas.size: float2
UICanvas.size =(value: float2)

Size of the image. This field can only be accessed in code. The same effect can be achieved by changing UIFrame.size property.

To change the value in editor use UIFrame.size of the node.

Arguments:
  • value : float2

UICanvas.pivot: float2
UICanvas.pivot =(value: float2)

Node’s origin relative to it’s content. Left-top of the content is (0,0), right-bottom is (1,1). Default is (0.5, 0.5).

Arguments:
  • value : float2

UICanvas.screenMode: ScreenMode
UICanvas.screenMode =(value: ScreenMode)

Indicates whether the UI canvas component should be displayed in fullscreen mode. Works only in ScreenSpaceOverlay mode.

Arguments: