UIText

Enumerations

TextEffect
Values:
  • None = 0 - Default text render

  • Shadow = 1 - Render text with shadow effect

  • Glow = 2 - Render text with glow effect

  • Outline = 3 - Render text with outline effect

TextHorAlignment
Values:
  • Left = 0 - Aligns text to the left border of bounding box

  • Center = 1 - Centers text horizontally according to bounding box width

  • Right = 2 - Aligns text to the right border of bounding box

TextVertAlignment
Values:
  • Top = 0 - Aligns text to the top border of bounding box

  • Middle = 1 - Centers text vertically according to bounding box height

  • Bottom = 2 - Aligns text to the bottom border of bounding box

Classes

UIText : NativeComponent

Note

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

This component is used to render UI text in Canvas.

The text is positioned in pixels from the center of the viewport. +X is to the right, +Y is to the top.

Example:

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

let textNode = create_node(NodeData(parent = canvas))
add_component(textNode, new UIText(
    text = "Hello, World!",
    horAlignment = Center,
    fontSize = 48.0
))
Properties:

UIText.text: string
UIText.text =(value: string)

UIText content to be rendered.

Arguments:
  • value : string

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

Pivot point of the text. The value is in the range of 0 to 1. Default is (0.5, 0.5).

Arguments:
  • value : float2

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

Size of the text’s bounding box. This field can only be accessed in code. The same effect can be achieved by changing UIFrame.size property of the node

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

Default is (0, 0) - means the box will be calculated automatically.

Arguments:
  • value : float2

UIText.localPosition2D: float2
UIText.localPosition2D =(value: float2)

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

Arguments:
  • value : float2

UIText.color: float4
UIText.color =(value: float4)

Color of the text. Default is white.

Arguments:
  • value : float4

UIText.fontSize: float
UIText.fontSize =(value: float)

Font height of the text. The size in pixels will be determined by the font and the scale of the node. Default is 16.0.

Arguments:
  • value : float

UIText.fontScaling: bool
UIText.fontScaling =(value: bool)

Font scaling. If enabled, applies node scale to the font instead of the text element. Default it true.

Arguments:
  • value : bool

UIText.fontId: FontId
UIText.fontId =(value: FontId)

Font resource id. Default is null it is equal to the default font.

Arguments:
UIText.effect: TextEffect
UIText.effect =(value: TextEffect)

UIText effect. Can be None, Shadow, Glow or Outline. Default is None.

Arguments:
UIText.effectColor: float4
UIText.effectColor =(value: float4)

Color of text effect. Default is white.

Arguments:
  • value : float4

UIText.effectOffset: float2
UIText.effectOffset =(value: float2)

Offset of the text effect. Default is (0, 0).

Arguments:
  • value : float2

UIText.effectThickness: float
UIText.effectThickness =(value: float)

Thickness of the text effect. Default is 1.

Arguments:
  • value : float

UIText.textSize: float2

Actual size of the text’s bounding box. This field is read-only.

UIText.rect: float4

Bounding box of the text. Its size is max(size, textSize). This field is read-only.

UIText.fontAutoSize: float2
UIText.fontAutoSize =(value: float2)

Limit of font size. Default is (0, 0) which means no limit is set.

Arguments:
  • value : float2

UIText.wordWrapping: bool
UIText.wordWrapping =(value: bool)

Word wrapping. Default is true.

If size is (0, 0) then word wrapping will not take effect.

Arguments:
  • value : bool

UIText.margin: float4
UIText.margin =(value: float4)

UIText margin (left, top, right, bottom). Default is (0, 0, 0, 0).

Arguments:
  • value : float4

UIText.horAlignment: TextHorAlignment
UIText.horAlignment =(value: TextHorAlignment)

Horizontal text alignment. Can be Left, Center or Right. Default is Center

Arguments:
UIText.vertAlignment: TextVertAlignment
UIText.vertAlignment =(value: TextVertAlignment)

Vertical text alignment. Can be Top, Middle or Bottom. Default is Middle

Arguments: