Interface IUIText
TMP-agnostic abstraction for a read-only or label-style UI text component.
Namespace: Scylla.Core.Util.UI
Assembly: ScyllaCore.dll
Syntax
public interface IUIText
Remarks
Consumers of this interface can read and update text content, styling, and
layout options without importing TextMeshPro directly. Implementations wrap
a TMP_Text component and delegate all method calls to it.
For zero-allocation per-frame text updates in hot paths use SetCharArray(char[], int, int) instead of assigning to Text.
Always check IsValid before calling any method if the underlying GameObject may have been destroyed between frames.
Properties
FontSize
Gets the current rendered font size in points.
Declaration
float FontSize { get; }
Property Value
| Type | Description |
|---|---|
| float | The font size applied to the underlying |
GameObject
Gets the UnityEngine.GameObject that hosts this text component.
Declaration
GameObject GameObject { get; }
Property Value
| Type | Description |
|---|---|
| GameObject | The root GameObject of the text element. |
IsValid
Gets whether this text component is valid and safe to use.
Declaration
bool IsValid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
RectTransform
Gets the RectTransform of the text element, used for anchoring, sizing, and placement within a layout.
Declaration
RectTransform RectTransform { get; }
Property Value
| Type | Description |
|---|---|
| RectTransform | The |
Text
Gets or sets the displayed text string.
Declaration
string Text { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The current text content. Setting this property allocates a managed string and triggers a TMP mesh rebuild. For frequent per-frame updates prefer SetCharArray(char[], int, int) to avoid allocations. |
Methods
SetAlignment(UIAlignment)
Sets the horizontal and vertical text alignment within the element's bounds.
Declaration
void SetAlignment(UIAlignment alignment)
Parameters
| Type | Name | Description |
|---|---|---|
| UIAlignment | alignment | The UIAlignment position to apply. The mapping to TMP's
|
SetCharArray(char[], int, int)
Updates the displayed text from a subsection of a character array without allocating a managed string.
Declaration
void SetCharArray(char[] chars, int start, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| char[] | chars | The source character array. Must not be |
| int | start | The zero-based index of the first character to copy from |
| int | length | The number of characters to copy starting at |
Remarks
This is the preferred method for high-frequency text updates such as timers, score counters, or live debug readouts because it avoids a heap allocation on every call.
SetColor(Color)
Sets the vertex color of all characters in this text element.
Declaration
void SetColor(Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | color | The UnityEngine.Color to apply. Rich text color tags embedded in the text string will override this base color for their respective spans when rich text is enabled. |
SetFont(UIFontReference)
Replaces the font asset used for rendering this text element.
Declaration
void SetFont(UIFontReference fontReference)
Parameters
| Type | Name | Description |
|---|---|---|
| UIFontReference | fontReference | A UIFontReference wrapping the desired |
SetFontSize(float)
Sets the font size in points.
Declaration
void SetFontSize(float size)
Parameters
| Type | Name | Description |
|---|---|---|
| float | size | The desired font size. Should fall within MIN_FONT_SIZE to MAX_FONT_SIZE. Values outside this range are accepted by TMP but may produce unusable results. |
SetFontStyle(UIFontStyle)
Applies a combination of font style flags to the text element.
Declaration
void SetFontStyle(UIFontStyle style)
Parameters
| Type | Name | Description |
|---|---|---|
| UIFontStyle | style | A UIFontStyle flags value. Multiple styles can be combined with
the bitwise OR operator, for example
|
SetRichText(bool)
Enables or disables TMP rich text tag parsing for this element.
Declaration
void SetRichText(bool enabled)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | enabled |
|
SetText(string)
Replaces the displayed text with the given string.
Declaration
void SetText(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The new text to display. Passing |
SetWordWrap(bool)
Enables or disables automatic line-breaking at word boundaries when the text exceeds the element's width.
Declaration
void SetWordWrap(bool enabled)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | enabled |
|