Skip to main content

InputField

A class in Root.Township, Alta.Meta.UI.

A text input field in the game's world-space menus, showing its text through a TextRenderer with an optional caret and secret (password) mode.

Constructors​

MemberWhat it is
InputField()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
bool isSecretWhether the text is shown masked with *.
5 private and internal fields
MemberWhat it is
private Transform caretThe caret transform set by SetupCaret, or null when the caret is off.
private string inputTextSerialized copy of the text, kept in step with InputText and used when toggling secret mode.
private int maxLengthDisplay length before the text is cut with "...". -1 means no limit. Doesn't limit what can be typed.
private UnityEvent onSubmitInspector event invoked by OnSubmit.
private TextRenderer textVisualsText renderer that shows the text, or asterisks in secret mode.

Properties​

MemberWhat it is
string InputText { get; private set; }The field's current text (the real value, not the masked display).

Events​

MemberWhat it is
event Action<InputField> InputChangedRaised whenever the text is set to something new.
event Action<InputField> SubmittedRaised when the field is submitted.

Methods​

MemberWhat it is
void DisableCaret()Stops moving the caret with the text.
void OnSubmit()Raises Submitted and the inspector's submit event.
void SetText(string newText)Sets the text and updates the display (masked with * if secret, cut to the max length otherwise).
void SetText(string newText, bool toggleSecret)Sets the text and updates the display (masked with * if secret, cut to the max length otherwise).
void SetupCaret(Transform caret)Attaches a caret transform that follows the end of the text.
void ToggleSecret()Flips secret mode and redraws the text.
1 private and internal method
MemberWhat it is
private void UpdateCaret()Moves the caret to the end of the current line of text, or the text start when empty.

Used in​

Members of other types that take, return or hold a InputField: