Class TextObject
A text display element
public sealed class TextObject : ArrangableElement, IGameObjectWrapper
- Inheritance
-
TextObject
- Implements
- Inherited Members
- Extension Methods
Constructors
TextObject(LayoutRoot, string)
Creates a text object
public TextObject(LayoutRoot onLayout, string name = "New TextObject")
Parameters
onLayout
LayoutRootThe layout to draw the text object on
name
stringThe name of the text object
Properties
ContentColor
The color of the text
public Color ContentColor { get; set; }
Property Value
Font
The font to use to draw text
public Font Font { get; set; }
Property Value
FontSize
The font size for the text
public int FontSize { get; set; }
Property Value
GameObject
The UnityEngine.GameObject underlying this UI element
public GameObject GameObject { get; }
Property Value
- GameObject
Inlines
Gets or sets a collection of styled text runs that define the content of this text object. When set, automatically joins the text content of all runs and updates the display. Use this property to create rich text with mixed formatting.
public RunCollection Inlines { get; set; }
Property Value
Examples
textObject.Inlines = [
new Run("Regular text "),
new Run("Bold text") { Bold = true },
new Run(" Red text") { Color = Color.red }
];
MaxHeight
The max height of the text. If text exceeds this height, it will be clipped.
public float MaxHeight { get; set; }
Property Value
MaxWidth
The max width of the text. If text exceeds this width, it will roll to the next line.
public float MaxWidth { get; set; }
Property Value
MeasureIsResolutionSensitive
Indicates whether an element's ability to accurately measure itself is sensitive to the display resolution. Such elements are automatically remeasured when the resolution changes
public override bool MeasureIsResolutionSensitive { get; }
Property Value
Text
The text of this element
public string Text { get; set; }
Property Value
TextAlignment
The alignment of the text within this element
public HorizontalAlignment TextAlignment { get; set; }
Property Value
Methods
ArrangeOverride(Vector2)
Internal implementation to position the object within the allocated space.
protected override void ArrangeOverride(Vector2 alignedTopLeftCorner)
Parameters
alignedTopLeftCorner
Vector2The space available for the element.
DestroyOverride()
Internal implementation to perform any additional cleanup when the element is destroyed
protected override void DestroyOverride()
MeasureOverride()
Internal implementation to calculate desired size.
protected override Vector2 MeasureOverride()