Class TextElement
Base class for a VisualElement that displays text.
Inherited Members
Namespace: UnityEngine.UIElements
Syntax
public class TextElement : BindableElement, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IBindable, ITextElement, INotifyValueChanged<string>
Constructors
TextElement()
Initializes and returns an instance of TextElement.
Declaration
public TextElement()
Fields
ussClassName
USS class name of elements of this type.
Declaration
public static readonly string ussClassName
Field Value
Type | Description |
---|---|
String |
Properties
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.
Declaration
public bool displayTooltipWhenElided { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
enableRichText
When false, rich text tags will not be parsed.
Declaration
public bool enableRichText { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
isElided
Returns true if text is elided, false otherwise.
Declaration
public bool isElided { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
Text is elided when the element that contains it is not large enough to display the full text, and has the following style property settings.
overflow: Overflow.Hidden whiteSpace: WhiteSpace.NoWrap textOverflow: TextOverflow.Ellipsis
The text Element hides elided text, and displays an ellipsis ('...') to indicate that there is hidden overflow content.
text
The text to be displayed.
Declaration
public virtual string text { get; set; }
Property Value
Type | Description |
---|---|
String |
Remarks
Changing this value will implicitly invoke the value setter, which will raise a ChangeEvent<T> of type string.
Methods
DoMeasure(Single, VisualElement.MeasureMode, Single, VisualElement.MeasureMode)
Declaration
protected override Vector2 DoMeasure(float desiredWidth, VisualElement.MeasureMode widthMode, float desiredHeight, VisualElement.MeasureMode heightMode)
Parameters
Type | Name | Description |
---|---|---|
Single | desiredWidth | |
VisualElement.MeasureMode | widthMode | |
Single | desiredHeight | |
VisualElement.MeasureMode | heightMode |
Returns
Type | Description |
---|---|
Vector2 |
Overrides
HandleEvent(EventBase)
Declaration
public override void HandleEvent(EventBase evt)
Parameters
Type | Name | Description |
---|---|---|
EventBase | evt |
Overrides
MeasureTextSize(String, Single, VisualElement.MeasureMode, Single, VisualElement.MeasureMode)
Computes the size needed to display a text string based on element style values such as font, font-size, word-wrap, and so on.
Declaration
public Vector2 MeasureTextSize(string textToMeasure, float width, VisualElement.MeasureMode widthMode, float height, VisualElement.MeasureMode heightMode)
Parameters
Type | Name | Description |
---|---|---|
String | textToMeasure | The text to measure. |
Single | width | Suggested width. Can be zero. |
VisualElement.MeasureMode | widthMode | Width restrictions. |
Single | height | Suggested height. |
VisualElement.MeasureMode | heightMode | Height restrictions. |
Returns
Type | Description |
---|---|
Vector2 | The horizontal and vertical size needed to display the text string. |
Explicit Interface Implementations
INotifyValueChanged<String>.SetValueWithoutNotify(String)
Declaration
void INotifyValueChanged<string>.SetValueWithoutNotify(string newValue)
Parameters
Type | Name | Description |
---|---|---|
String | newValue |
Implements
INotifyValueChanged<String>.value
Declaration
string INotifyValueChanged<string>.value { get; set; }
Returns
Type | Description |
---|---|
String |