Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


TextElement

Use this as the super class if you are declaring a custom VisualElement that displays text. For example, Button or Label use this as their base class. For more information, refer to UXML element TextElement.
Read time 9 minutesLast updated 5 days ago

Definition

[UxmlElement]public class TextElement : BindableElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IVisualElementScheduler, ICustomStyle, IBindable, INotifyValueChanged<string>, ITextEdition, ITextElementExperimentalFeatures, IExperimentalFeatures, ITextSelection

Static Fields

Value

Description

selectableUssClassNameUSS class name of selectable text elements.
ussClassNameUSS class name of elements of this type.

Constructors

Constructor

Description

TextElement()Initializes and returns an instance of TextElement.

Properties

Property

Description

displayTooltipWhenElidedWhen true, a tooltip displays the full version of elided text, and also if a tooltip had been previously provided, it will be overwritten.
emojiFallbackSupportSpecifies the order in which the system should look for Emoji characters when rendering text. If this setting is enabled, the global Emoji Fallback list will be searched first for characters defined as Emoji in the Unicode 14.0 standard.
enableRichTextWhen false, rich text tags will not be parsed.
experimentalReturns the TextElement experimental interface.
isElidedReturns true if text is elided, false otherwise.
parsedTextThe text as it is laid out, after rich text tags are parsed out and text transforms are applied. _textRange indexes into this string.
parseEscapeSequencesDetermines how escape sequences are displayed. When set to
true
, escape sequences (such as
\n
,
\t
) are parsed and transformed into their corresponding characters. For example, '\n' will insert a new line. When set to
false
, escape sequences are displayed as raw text (for example,
\n
is shown as the characters '' followed by 'n').
PostProcessTextVerticesCallback fired after UI Toolkit has generated the vertex data for a TextElement and before the geometry is sent to the renderer. Use it to inspect or modify each glyph’s quad (position, tint, UVs, etc.) to implement custom per‑glyph effects.
selectionRetrieves this TextElement's ITextSelection
textThe text to be displayed.

Methods

Method

Description

MarkDirtyTextMarks that the TextElement forces a layout and repaint.
MeasureTextSizeComputes the size needed to display a text string based on element style values such as font, font-size, word-wrap, and so on.
SetTextSets the text content from a character array slice without allocating a managed string.

Structs

Struct

Description

TextElement.GlyphEncapsulates a single glyph rendered inside a TextElement mesh. A glyph is a quad made of four vertices, laid out clockwise: bottom‑left → top‑left → top‑right → bottom‑right
TextElement.GlyphsEnumerableEnumerates all visible glyphs in the order they appear on screen.
TextElement.GlyphsEnumeratorIterates over glyphs in visual order.

Enums

Enum

Description

TextElement.GlyphKindClassifies what a TextElement.Glyph represents. ATG-only; the legacy TextCore generator always reports TextElement.GlyphKind.Character.

Inheritance

Inherited Members