Editable text input field.
Inheritance
TMP_InputField
Namespace: TMPro
public class TMP_InputField : Selectable, IUpdateSelectedHandler, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerClickHandler, ISubmitHandler, ICanvasElement, IScrollHandler
Constructors
Declaration
protected TMP_InputField()
Fields
Declaration
protected int m_CaretPosition
Field Value
Declaration
protected int m_CaretSelectPosition
Field Value
Declaration
protected bool m_CaretVisible
Field Value
Declaration
protected UIVertex[] m_CursorVerts
Field Value
Type |
Description |
UIVertex[] |
|
Declaration
protected TMP_FontAsset m_GlobalFontAsset
Field Value
Declaration
protected TMP_InputValidator m_InputValidator
Field Value
m_isRichTextEditingAllowed
Declaration
protected bool m_isRichTextEditingAllowed
Field Value
Declaration
protected bool m_isSelectAll
Field Value
Declaration
protected TouchScreenKeyboard m_Keyboard
Field Value
Type |
Description |
TouchScreenKeyboard |
|
Declaration
[NonSerialized]
protected Mesh m_Mesh
Field Value
Declaration
protected bool m_OnFocusSelectAll
Field Value
Declaration
protected Graphic m_Placeholder
Field Value
Declaration
protected bool m_ResetOnDeActivation
Field Value
Declaration
protected float m_ScrollSensitivity
Field Value
Declaration
protected int m_StringPosition
Field Value
Declaration
protected int m_StringSelectPosition
Field Value
m_Text
Declaration
Field Value
m_TextComponent
Declaration
protected TMP_Text m_TextComponent
Field Value
m_TextComponentRectTransform
Declaration
protected RectTransform m_TextComponentRectTransform
Field Value
Type |
Description |
RectTransform |
|
m_TextViewport
Text Text used to display the input's value.
Declaration
protected RectTransform m_TextViewport
Field Value
Type |
Description |
RectTransform |
|
Declaration
protected Scrollbar m_VerticalScrollbar
Field Value
Type |
Description |
Scrollbar |
|
Declaration
protected TMP_ScrollbarEventHandler m_VerticalScrollbarEventHandler
Field Value
Properties
Declaration
public char asteriskChar { get; set; }
Property Value
Declaration
public float caretBlinkRate { get; set; }
Property Value
Declaration
public Color caretColor { get; set; }
Property Value
Get: Returns the focus position as thats the position that moves around even during selection.
Set: Set both the anchor and focus position such that a selection doesn't happen
Declaration
public int caretPosition { get; set; }
Property Value
Current position of the cursor.
Getters are public Setters are protected
Declaration
protected int caretPositionInternal { get; set; }
Property Value
Declaration
protected int caretSelectPositionInternal { get; set; }
Property Value
Declaration
public int caretWidth { get; set; }
Property Value
Declaration
public int characterLimit { get; set; }
Property Value
Declaration
public TMP_InputField.CharacterValidation characterValidation { get; set; }
Property Value
contentType
Declaration
public TMP_InputField.ContentType contentType { get; set; }
Property Value
Declaration
public bool customCaretColor { get; set; }
Property Value
Sets the Font Asset on both Placeholder and Input child objects.
Declaration
public TMP_FontAsset fontAsset { get; set; }
Property Value
Declaration
public TMP_InputField.InputType inputType { get; set; }
Property Value
Sets the Input Validation to use a Custom Input Validation script.
Declaration
public TMP_InputValidator inputValidator { get; set; }
Property Value
Declaration
public bool isFocused { get; }
Property Value
isRichTextEditingAllowed
Is Rich Text editing allowed?
Declaration
public bool isRichTextEditingAllowed { get; set; }
Property Value
Declaration
public TouchScreenKeyboardType keyboardType { get; set; }
Property Value
Type |
Description |
TouchScreenKeyboardType |
|
Declaration
public TMP_InputField.LineType lineType { get; set; }
Property Value
Declaration
protected Mesh mesh { get; }
Property Value
Declaration
public bool multiLine { get; }
Property Value
Declaration
public TMP_InputField.SelectionEvent onDeselect { get; set; }
Property Value
Declaration
public TMP_InputField.SubmitEvent onEndEdit { get; set; }
Property Value
onEndTextSelection
Declaration
public TMP_InputField.TextSelectionEvent onEndTextSelection { get; set; }
Property Value
Determines if the whole text will be selected when focused.
Declaration
public bool onFocusSelectAll { get; set; }
Property Value
Declaration
public TMP_InputField.SelectionEvent onSelect { get; set; }
Property Value
Declaration
public TMP_InputField.SubmitEvent onSubmit { get; set; }
Property Value
onTextSelection
Declaration
public TMP_InputField.TextSelectionEvent onTextSelection { get; set; }
Property Value
Declaration
public TMP_InputField.OnValidateInput onValidateInput { get; set; }
Property Value
Declaration
public TMP_InputField.OnChangeEvent onValueChanged { get; set; }
Property Value
Declaration
public Graphic placeholder { get; set; }
Property Value
Set the point size on both Placeholder and Input text object.
Declaration
public float pointSize { get; set; }
Property Value
Declaration
public bool readOnly { get; set; }
Property Value
Determines if the text and caret position as well as selection will be reset when the input field is deactivated.
Declaration
public bool resetOnDeActivation { get; set; }
Property Value
restoreOriginalTextOnEscape
Controls whether the original text is restored when pressing "ESC".
Declaration
public bool restoreOriginalTextOnEscape { get; set; }
Property Value
richText
Declaration
public bool richText { get; set; }
Property Value
Declaration
public float scrollSensitivity { get; set; }
Property Value
Get: Returns the fixed position of selection
Set: If Input.compositionString is 0 set the fixed position
Declaration
public int selectionAnchorPosition { get; set; }
Property Value
Declaration
public Color selectionColor { get; set; }
Property Value
Get: Returns the variable position of selection
Set: If Input.compositionString is 0 set the variable position
Declaration
public int selectionFocusPosition { get; set; }
Property Value
The fixed position of the selection in the raw string which may contains rich text.
Declaration
public int selectionStringAnchorPosition { get; set; }
Property Value
The variable position of the selection in the raw string which may contains rich text.
Declaration
public int selectionStringFocusPosition { get; set; }
Property Value
Should the mobile keyboard input be hidden.
Declaration
public bool shouldHideMobileInput { get; set; }
Property Value
Declaration
public int stringPosition { get; set; }
Property Value
Declaration
protected int stringPositionInternal { get; set; }
Property Value
Declaration
protected int stringSelectPositionInternal { get; set; }
Property Value
text
Input field's current text value.
Declaration
public string text { get; set; }
Property Value
textComponent
Declaration
public TMP_Text textComponent { get; set; }
Property Value
textViewport
Declaration
public RectTransform textViewport { get; set; }
Property Value
Type |
Description |
RectTransform |
|
Declaration
public Scrollbar verticalScrollbar { get; set; }
Property Value
Type |
Description |
Scrollbar |
|
Declaration
public bool wasCanceled { get; }
Property Value
Methods
Declaration
public void ActivateInputField()
Declaration
protected virtual void Append(char input)
Parameters
Type |
Name |
Description |
Char |
input |
|
Append the specified text to the end of the current.
Declaration
protected virtual void Append(string input)
Parameters
Type |
Name |
Description |
String |
input |
|
Declaration
protected void ClampCaretPos(ref int pos)
Parameters
Type |
Name |
Description |
Int32 |
pos |
|
Declaration
protected void ClampStringPos(ref int pos)
Parameters
Type |
Name |
Description |
Int32 |
pos |
|
Declaration
public void DeactivateInputField()
Declaration
protected override void DoStateTransition(SelectionState state, bool instant)
Parameters
Type |
Name |
Description |
SelectionState |
state |
|
Boolean |
instant |
|
Declaration
public void ForceLabelUpdate()
Declaration
public virtual void GraphicUpdateComplete()
Declaration
protected TMP_InputField.EditState KeyPressed(Event evt)
Parameters
Type |
Name |
Description |
Event |
evt |
|
Returns
Update the text based on input.
Declaration
protected virtual void LateUpdate()
Declaration
public virtual void LayoutComplete()
MoveTextEnd(Boolean)
Move to the end of the text.
Declaration
public void MoveTextEnd(bool shift)
Parameters
Type |
Name |
Description |
Boolean |
shift |
|
MoveTextStart(Boolean)
Move to the start of the text.
Declaration
public void MoveTextStart(bool shift)
Parameters
Type |
Name |
Description |
Boolean |
shift |
|
Move to the end of the current line of text.
Declaration
public void MoveToEndOfLine(bool shift, bool ctrl)
Parameters
Move to the start of the current line of text.
Declaration
public void MoveToStartOfLine(bool shift, bool ctrl)
Parameters
Declaration
public virtual void OnBeginDrag(PointerEventData eventData)
Parameters
Type |
Name |
Description |
PointerEventData |
eventData |
|
Declaration
public void OnControlClick()
Declaration
public override void OnDeselect(BaseEventData eventData)
Parameters
Type |
Name |
Description |
BaseEventData |
eventData |
|
Declaration
protected override void OnDisable()
Declaration
public virtual void OnDrag(PointerEventData eventData)
Parameters
Type |
Name |
Description |
PointerEventData |
eventData |
|
Declaration
protected override void OnEnable()
Declaration
public virtual void OnEndDrag(PointerEventData eventData)
Parameters
Type |
Name |
Description |
PointerEventData |
eventData |
|
Declaration
Declaration
public virtual void OnPointerClick(PointerEventData eventData)
Parameters
Type |
Name |
Description |
PointerEventData |
eventData |
|
Declaration
public override void OnPointerDown(PointerEventData eventData)
Parameters
Type |
Name |
Description |
PointerEventData |
eventData |
|
Declaration
public virtual void OnScroll(PointerEventData eventData)
Parameters
Type |
Name |
Description |
PointerEventData |
eventData |
|
Declaration
public override void OnSelect(BaseEventData eventData)
Parameters
Type |
Name |
Description |
BaseEventData |
eventData |
|
Declaration
public virtual void OnSubmit(BaseEventData eventData)
Parameters
Type |
Name |
Description |
BaseEventData |
eventData |
|
Declaration
public virtual void OnUpdateSelected(BaseEventData eventData)
Parameters
Type |
Name |
Description |
BaseEventData |
eventData |
|
Declaration
public void ProcessEvent(Event e)
Parameters
Type |
Name |
Description |
Event |
e |
|
Declaration
public virtual void Rebuild(CanvasUpdate update)
Parameters
Type |
Name |
Description |
CanvasUpdate |
update |
|
Declaration
protected void SelectAll()
Submit the input field's text.
Declaration
protected void SendOnEndEdit()
SendOnEndTextSelection()
Declaration
protected void SendOnEndTextSelection()
Declaration
protected void SendOnFocus()
Declaration
protected void SendOnFocusLost()
Declaration
protected void SendOnSubmit()
SendOnTextSelection()
Declaration
protected void SendOnTextSelection()
Function to conveniently set the Font Asset of both Placeholder and Input Field text object.
Declaration
public void SetGlobalFontAsset(TMP_FontAsset fontAsset)
Parameters
Function to conveniently set the point size of both Placeholder and Input Field text object.
Declaration
public void SetGlobalPointSize(float pointSize)
Parameters
Type |
Name |
Description |
Single |
pointSize |
|
Update the visual text Text.
Declaration
protected void UpdateLabel()
Validate the specified input.
Declaration
protected char Validate(string text, int pos, char ch)
Parameters
Returns