Legacy Documentation: Version 4.6.2
Language: English
Scroll Rect
Auto Layout

Input Field

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

An Input Field is a way to make the text of a Text Control editable. Like the other interaction controls, it’s not a visible UI element in itself and must be combined with one or more visual UI elements in order to be visible.

An empty Input Field.
An empty Input Field.
Text entered into the Input Field.
Text entered into the Input Field.

Properties

Property: Function:
Text The Text control to be made editable by this Input Field.
Starting Value The initial text placed in the field before editing begins.
Character Limit The maximum number of characters that the user can type into the field.
Active Text Color The color of the editable text (which may be different from the color specified in the Text control).
Selection Color The background color of the selected portion of text.
Multi Line Should the field let the user insert line breaks with the enter/return key?
Interactable Will this component will accept input? See Interactable.
Transition Properties that determine the way the control responds visually to user actions. See Transition Options.
Navigation Properties that determine the sequence of controls. See Navigation Options.

Events

Property: Function:
On Value Change A UnityEvent that is invoked when the text content of the Input Field changes. The event can send the current text content as a string type dynamic argument.
End Edit A UnityEvent that is invoked when the user finishes editing the text content either by submitting or by clicking somewhere that removes the focus from the Input Field. The event can send the current text content as a string type dynamic argument.

Details

The Input Field script can be added to any existing Text control object from the menu (Component > UI > Input Field). Having done this, you should also drag the object to the Input Field’s Text property to enable editing.

The Text property of the Text control itself will change as the user types and the value can be retrieved from a script after editing. Note that Rich Text is intentionally not supported for editable Text controls; the field will apply any Rich Text markup instantly when typed but the markup essentially “disappears” and there is no subsequent way to change or remove the styling.

Scroll Rect
Auto Layout