Preparing search index...

    Class Text

    Renders 2D text with specific style and layout.

    Supports Dynamic Text.

    Text guide.

    //@input Component.Text textComponent
    //@input Asset.Font customFont
    //@input vec4 color {"widget":"color"}

    script.textComponent.text = "Hello there";
    script.textComponent.font = script.customFont;
    script.textComponent.size = 30;
    script.textComponent.verticalOverflow = VerticalOverflow.Truncate;
    script.textComponent.textFill.color = script.color;
    // @input Component.Text textComponent
    // @input Component.ScreenTransform background

    // Reparent the background object to be a child of the Text object
    var textObj = script.textComponent.getSceneObject();
    script.background.getSceneObject().setParent(textObj);

    // Set the background object to be the extentsTarget of the Text object, so it matches the rendered area
    script.textComponent.extentsTarget = script.background;

    Hierarchy (View Summary)

    Index

    Properties

    backgroundSettings: BackgroundSettings

    Settings for drawing a background behind the text.

    blendMode: BlendMode

    How the text should be blended during rendering.

    Lens Scripting Version 324

    BlendMode.PremultipliedAlphaHardware
    
    capitilizationOverride: CapitilizationOverride

    Overrides the capitalization of the text rendered.

    CapitilizationOverride.None
    
    colorMask: vec4b

    Controls the masking of color channels with a vec4b representing each channel with a boolean.

    Lens Scripting Version 149

    (true, true, true, true)
    
    debugRenderLayoutRect: boolean

    If enabled, draws the Text#layoutRect bounds as a wireframe for debugging text layout. Has no effect when a ScreenTransform is attached to the same SceneObject, since the ScreenTransform supersedes the layoutRect.

    Lens Scripting Version 364

    false
    
    depthTest: boolean

    If enabled, the text material will use Depth Testing. Useful when Text exists in 3D space.

    false
    
    dropshadowSettings: DropshadowSettings

    Settings for how dropshadow is used in text drawing.

    editable: boolean

    Makes the Text component editable. When this is enabled the Text can be clicked to open up the device keyboard and edit the contents.

    Lens Scripting Version 165

    false
    
    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    true
    
    enableRichText: boolean

    If enabled, inputted text will be interpreted as rich text.

    Lens Scripting Version 356

    false
    
    extentsTarget: ScreenTransform

    When a ScreenTransform is present on this SceneObject, and extentsTarget is a child of this SceneObject, extentsTarget will be repositioned to match the exact area this MeshVisual is being rendered. Very useful for Image and Text components.

    null
    
    font: Font

    Font asset used.

    Setting this will override any existing Font, FontFamily, or FontCollection asset assigned as the font source of the text component. If there is a FontFamily or FontCollection asset currently assigned as the font source, reading this will return null.

    null
    

    The font source for this text component. Can be a Font, FontFamily, or FontCollection asset.

    Lens Scripting Version 356

    null
    
    horizontalAlignment: HorizontalAlignment

    When a ScreenTransform is attached to the same SceneObject, this controls how the mesh will be positioned horizontally depending on stretchMode.

    HorizontalAlignment.Center
    
    horizontalOverflow: HorizontalOverflow

    Controls how text should be handled when it goes past the horizontal boundaries defined by ScreenTransform or Text#layoutRect, with the former taking precedence.

    HorizontalOverflow.Overflow
    
    isBeingDestroyed: boolean

    Returns true if this Component is currently being destroyed. Becomes true as soon as destruction begins via Component#destroy or destruction of its owning SceneObject, before any OnDestroyEvent callbacks fire.

    Lens Scripting Version 364

    if (!script.isBeingDestroyed) {
    // Component is still fully alive
    }
    isEnabledInHierarchy: boolean

    Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.

    italic: boolean

    If enabled, the rendered text will try to use an italic font style.

    Lens Scripting Version 325

    false
    
    layoutRect: Rect

    The rectangular bounds the text is laid out within. Controls text wrapping and alignment, and defines the area Text#horizontalOverflow, Text#verticalOverflow, and Text#sizeToFit are evaluated against.

    Each bound is defined as an offset in world units from the SceneObject's position.

    If a ScreenTransform is attached to the same SceneObject, it always supersedes this property — text is laid out within the ScreenTransform's rect instead, and changes to layoutRect have no effect.

    Lens Scripting Version 364

    letterSpacing: number

    Modifies the spacing between letters. A value of 0 uses the font's normal letter spacing. Negative values will remove space between letters, and positive values will add more space between letters.

    0
    
    lineSpacing: number

    Modifies the vertical spacing between lines, as a multiple of lines. 1 will be single spacing, 2 will be double spaced, and 0.5 would be half the normal line height.

    Lens Scripting Version 153

    1
    
    meshShadowMode: MeshShadowMode

    None = 0, Caster = 1, Receiver = 2

    MeshShadowMode.None
    
    onEditingFinished: event1<string, void>

    This event will notify you when the user finishes editing the text.

    onEditingStarted: event0<void>

    This event will notify you when the input keyboard opens.

    onEditingUpdated: event1<string, void>

    This event will notify you on every edit to the text while the user is typing.

    outlineSettings: OutlineSettings

    Settings for how text outline is used in text drawing.

    renderOrder: number

    The order in which the visual should be rendered.

    Lens Scripting Version 323

    0
    
    sceneObject: SceneObject

    The SceneObject this component is on.

    shadowColor: vec4

    Affects the color of shadows being cast by this MeshVisual. The color of the cast shadow is a mix between shadowColor and the material's base texture color. The alpha value of shadowColor controls the mixing of these two colors, with 0 = shadowColor and 1 = shadowColor * textureColor.

    (1, 1, 1, 1)
    
    shadowDensity: number

    Density of shadows cast by this MeshVisual.

    1
    
    showEditingPreview: boolean

    Use this property to control whether to show the input preview the keyboard. Note this preview also enables cursor movement.

    Lens Scripting Version 170

    true
    
    size: number

    Font size used. Minimum of 2.0 and maximum of 800.0.

    size sets the em square height of the rendered text.

    In world space, the em square height in centimeters is size / 43.886, so the default size of 48 produces an em square ~1.09 cm tall.

    Under a Canvas in Pixels or Points mode, Text scales as though the camera's orthographic size were the default 20 cm regardless of the actual camera size. The em square is renderTargetHeightPoints * size / 877.71 points tall — about 39 points for the default size of 48 on a render target 720 points tall. The pixel form is the same expression with the render target height in pixels.

    48
    
    sizeToFit: boolean

    If enabled, the rendered text will always scale to fit the boundaries defined by ScreenTransform or Text#layoutRect, with the former taking precedence.

    false
    
    stretchMode: StretchMode

    When a ScreenTransform is attached to the same SceneObject, this controls how the mesh will be stretched relative to the ScreenTransform's boundaries.

    StretchMode.Stretch
    
    text: string

    Text string to be drawn.

    ""
    
    textFill: TextFill

    Settings for how the text is drawn, such as fill color or texture.

    touchHandler: InteractionComponent

    Use this property to override the touch handling for when to open the device keyboard when the Text is editable.

    Lens Scripting Version 165

    null
    
    twoSided: boolean

    Whether the text should be visible in both front and back.

    Lens Scripting Version 274

    false
    
    uniqueIdentifier: string

    Lens Scripting Version 176

    verticalAlignment: VerticalAlignment

    When a ScreenTransform is attached to the same SceneObject, this controls how the mesh will be positioned vertically depending on stretchMode.

    VerticalAlignment.Center
    
    verticalOverflow: VerticalOverflow

    Controls how text should be handled when it goes past the vertical boundaries defined by ScreenTransform or Text#layoutRect, with the former taking precedence.

    VerticalOverflow.Overflow
    
    weight: number

    Controls the font weight. Usually a multiple of 100 between 100 and 900 inclusively. Will use closest font weight available on the system.

    Lens Scripting Version 325

    400
    
    worldSpaceRect: Rect

    Use Text#layoutRect instead.

    Lens Scripting Version 364

    Methods

    • Gets the bounding box encompassing the characters in the range from start to end. The range is inclusive of start and exclusive of end.

      Parameters

      • Optionalstart: number
      • Optionalend: number

      Returns Rect

      Lens Scripting Version 316

    • Returns the recommended height for a cursor visual, in the same coordinate space as getCursorPositions(). The height is derived from the font size and accounts for scaling (e.g. VerticalOverflow.Shrink or sizeToFit).

      Returns number

      Lens Scripting Version 361

    • Returns a list of cursor positions for each character in the current text. Not supported when rich text is enabled.

      Returns CursorPosition[]

      Lens Scripting Version 324

    • Returns a list of rectangles highlighting the characters in the range from start to end. Each rectangle covers one contiguous visual run of text within the range, so a single line with mixed text directions may produce multiple rectangles. The range is inclusive of start and exclusive of end.

      Parameters

      • Optionalstart: number
      • Optionalend: number

      Returns Rect[]

      Lens Scripting Version 362

    • 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

    • Range maximum of the local-space axis-aligned bounding box (AABB) of the visual.

      Returns vec3

      Lens Scripting Version 156

    • Range minimum of the local-space axis-aligned bounding box (AABB) of the visual.

      Returns vec3

      Lens Scripting Version 156

    • Sets the order of this Visual in the render queue.

      Parameters

      • value: number

      Returns void

    • Projects screen positions from camera's view onto the mesh's UVs. If the MeshVisual's material uses the same texture as the camera input, the MeshVisual will look identical to the part of the screen it covers.

      Parameters

      Returns void

    • Range maximum of the world-space axis-aligned bounding box (AABB) of the visual.

      Returns vec3

      Lens Scripting Version 156

    • Range minimum of the world-space axis-aligned bounding box (AABB) of the visual.

      Returns vec3

      Lens Scripting Version 156