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 8 minutesLast updated 5 days ago
Definition
- Type: Class
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
- Inherits from: BindableElement
- Implements: IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IVisualElementScheduler, IBindable, INotifyValueChanged<string>, ITextEdition, ITextElementExperimentalFeatures, IExperimentalFeatures, ITextSelection
public class TextElement : BindableElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IVisualElementScheduler, 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. |
| 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. |
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. |