Table of Contents

Class TextObject

Namespace
MagicUI.Elements
Assembly
MagicUI.dll

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 LayoutRoot

The layout to draw the text object on

name string

The name of the text object

Properties

ContentColor

The color of the text

public Color ContentColor { get; set; }

Property Value

Color

Font

The font to use to draw text

public Font Font { get; set; }

Property Value

Font

FontSize

The font size for the text

public int FontSize { get; set; }

Property Value

int

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

RunCollection

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

float

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

float

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

bool

Text

The text of this element

public string Text { get; set; }

Property Value

string

TextAlignment

The alignment of the text within this element

public HorizontalAlignment TextAlignment { get; set; }

Property Value

HorizontalAlignment

Methods

ArrangeOverride(Vector2)

Internal implementation to position the object within the allocated space.

protected override void ArrangeOverride(Vector2 alignedTopLeftCorner)

Parameters

alignedTopLeftCorner Vector2

The 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()

Returns

Vector2