Interface IUITextField
TMP-agnostic abstraction for a single-line or multi-line text input field.
Inherited Members
Namespace: Scylla.Core.Util.UI
Assembly: ScyllaCore.dll
Syntax
public interface IUITextField : IDisposable
Remarks
Consumers of this interface never need to import TextMeshPro directly. All styling, interaction, and event-handling operations are exposed through TMP-free members, making it straightforward to swap the underlying implementation or create test doubles.
Implementors are responsible for registering and unregistering all TMP event listeners. Disposing an instance via Dispose() must safely clean up those subscriptions and may destroy the underlying GameObject depending on the implementation.
Properties
CaretPosition
Gets or sets the zero-based index of the text cursor position within Text.
Declaration
int CaretPosition { get; set; }
Property Value
| Type | Description |
|---|---|
| int | A value between |
GameObject
Gets the UnityEngine.GameObject that hosts this input field component.
Declaration
GameObject GameObject { get; }
Property Value
| Type | Description |
|---|---|
| GameObject | The root GameObject of the input field widget. |
Interactable
Gets or sets whether the input field responds to user interaction.
Declaration
bool Interactable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
IsFocused
Gets whether the input field currently has keyboard focus.
Declaration
bool IsFocused { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
RectTransform
Gets the RectTransform of the input field root, used for anchoring, sizing, and layout group placement.
Declaration
RectTransform RectTransform { get; }
Property Value
| Type | Description |
|---|---|
| RectTransform | The |
Text
Gets or sets the current text content of the input field.
Declaration
string Text { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The raw string value typed by the user. Setting this value replaces the entire content and fires OnValueChanged if the new value differs from the previous one. |
Methods
Clear()
Clears all text content, setting Text to an empty string.
Declaration
void Clear()
Remarks
Implementations should fire OnValueChanged with an empty string when the previous content was non-empty.
Focus()
Activates the input field and gives it keyboard focus, placing the cursor at the end of the current text.
Declaration
void Focus()
SetCaretColor(Color)
Sets the color of the blinking text cursor (caret).
Declaration
void SetCaretColor(Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | color | The UnityEngine.Color to apply to the caret graphic. |
SetCharacterFilter(Func<char, bool>)
Installs a per-character filter that controls which characters may be appended to the field's text.
Declaration
void SetCharacterFilter(Func<char, bool> filter)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<char, bool> | filter | A predicate that receives each candidate character and returns |
Remarks
The filter is evaluated before OnValueChanged fires. Characters rejected by the filter are silently discarded and do not appear in the field.
A common use case is restricting input to digits-only:
inputField.SetCharacterFilter(c => char.IsDigit(c));
SetFont(UIFontReference)
Replaces the current font asset used by the input field.
Declaration
void SetFont(UIFontReference fontReference)
Parameters
| Type | Name | Description |
|---|---|---|
| UIFontReference | fontReference | A UIFontReference that wraps the desired |
SetFontSize(float)
Sets the font size of the input text in points.
Declaration
void SetFontSize(float size)
Parameters
| Type | Name | Description |
|---|---|---|
| float | size | The desired font size. Should be a positive value within the range MIN_FONT_SIZE to MAX_FONT_SIZE. |
SetPlaceholderColor(Color)
Sets the color of the placeholder text that appears when the field is empty.
Declaration
void SetPlaceholderColor(Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | color | The UnityEngine.Color for the placeholder. Typically a semi-transparent version of the text color to visually distinguish it from real input. |
SetTextColor(Color)
Sets the color of the input text.
Declaration
void SetTextColor(Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | color | The UnityEngine.Color to apply to the typed text. The alpha component controls transparency. |
Unfocus()
Removes keyboard focus from the input field without clearing its content.
Declaration
void Unfocus()
Events
OnSubmit
Raised when the user confirms their input by pressing Enter (or the platform submit key), providing the final text value.
Declaration
event Action<string> OnSubmit
Event Type
| Type | Description |
|---|---|
| Action<string> |
Remarks
The string argument is equivalent to Text at the moment of submission. The field is not automatically cleared or unfocused on submit; call Clear() or Unfocus() explicitly if needed.
OnValueChanged
Raised each time the text content changes, either from user typing or a programmatic assignment to Text.
Declaration
event Action<string> OnValueChanged
Event Type
| Type | Description |
|---|---|
| Action<string> |
Remarks
The string argument contains the complete current value of the field after the change, not just the delta.