On this page

label

Functions to manipulate a label component.

Functions

label.set_text(url: string | Hash | Url, text: string | number)

Sets the text of a label component This method uses the message passing that means the value will be set after dispatch messages step. More information is available in the Application Lifecycle manual.

export default defineScript({
  init(self) {
    label.set_text("#label", "Hello World!");
  },
});

Parameters

  • url: string | Hash | Url — the label that should have a constant set
  • text: string | number — the text

label.get_text(url: string | Hash | Url): string

Gets the text from a label component

export default defineScript({
  init(self) {
    const text = label.get_text("#label");
    print(text);
  },
});

Parameters

  • url: string | Hash | Url — the label to get the text from

Returns

  • metrics: string — the label text

Properties

color: Vector4

The color of the label. The type of the property is vector4.

outline: Vector4

The outline color of the label. The type of the property is vector4.

shadow: Vector4

The shadow color of the label. The type of the property is vector4.

scale: number | Vector3

The scale of the label. The type of the property is number (uniform) or vector3 (non uniform).

size: Vector3

Returns the size of the label. The size will constrain the text if line break is enabled. The type of the property is vector3.

material: Hash

The material used when rendering the label. The type of the property is hash.

font: Hash

The font used when rendering the label. The type of the property is hash.

leading: number

The leading of the label. This value is used to scale the line spacing of text. The type of the property is number.

tracking: number

The tracking of the label. This value is used to adjust the vertical spacing of characters in the text. The type of the property is number.

line_break: boolean

The line break of the label. This value is used to adjust the vertical spacing of characters in the text. The type of the property is boolean.