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
- Type: Class
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
- Inherits from: BindableElement
- Implements: IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IVisualElementScheduler, ICustomStyle, IBindable, INotifyValueChanged<string>, ITextEdition, ITextElementExperimentalFeatures, IExperimentalFeatures, ITextSelection
[UxmlElement]public class TextElement : BindableElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IVisualElementScheduler, ICustomStyle, IBindable, INotifyValueChanged<string>, ITextEdition, ITextElementExperimentalFeatures, IExperimentalFeatures, ITextSelection
Static Fields
Value | Description |
|---|---|
| selectableUssClassName | USS class name of selectable text elements. |
| ussClassName | USS class name of elements of this type. |
Constructors
Constructor | Description |
|---|---|
| TextElement() | Initializes and returns an instance of TextElement. |
Properties
Property | Description |
|---|---|
| displayTooltipWhenElided | When true, a tooltip displays the full version of elided text, and also if a tooltip had been previously provided, it will be overwritten. |
| emojiFallbackSupport | Specifies 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. |
| enableRichText | When false, rich text tags will not be parsed. |
| experimental | Returns the TextElement experimental interface. |
| isElided | Returns true if text is elided, false otherwise. |
| parsedText | The text as it is laid out, after rich text tags are parsed out and text transforms are applied. _textRange indexes into this string. |
| parseEscapeSequences | Determines how escape sequences are displayed. When set to |
| PostProcessTextVertices | Callback 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. |
| selection | Retrieves this TextElement's ITextSelection |
| text | The text to be displayed. |
Methods
Method | Description |
|---|---|
| MarkDirtyText | Marks that the TextElement forces a layout and repaint. |
| MeasureTextSize | Computes the size needed to display a text string based on element style values such as font, font-size, word-wrap, and so on. |
| SetText | Sets the text content from a character array slice without allocating a managed string. |
Structs
Struct | Description |
|---|---|
| TextElement.Glyph | Encapsulates 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.GlyphsEnumerable | Enumerates all visible glyphs in the order they appear on screen. |
| TextElement.GlyphsEnumerator | Iterates over glyphs in visual order. |
Enums
Enum | Description |
|---|---|
| TextElement.GlyphKind | Classifies what a TextElement.Glyph represents. ATG-only; the legacy TextCore generator always reports TextElement.GlyphKind.Character. |