docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TMP_InputField

    Editable text input field.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    UIBehaviour
    Selectable
    TMP_InputField
    Implements
    IMoveHandler
    IPointerDownHandler
    IPointerUpHandler
    IPointerEnterHandler
    IPointerExitHandler
    ISelectHandler
    IDeselectHandler
    IUpdateSelectedHandler
    IBeginDragHandler
    IDragHandler
    IEndDragHandler
    IPointerClickHandler
    ISubmitHandler
    ICancelHandler
    ICanvasElement
    ILayoutElement
    IScrollHandler
    IEventSystemHandler
    Inherited Members
    Selectable.s_Selectables
    Selectable.s_SelectableCount
    Selectable.allSelectablesArray
    Selectable.allSelectableCount
    Selectable.allSelectables
    Selectable.AllSelectablesNoAlloc(Selectable[])
    Selectable.m_CurrentIndex
    Selectable.navigation
    Selectable.transition
    Selectable.colors
    Selectable.spriteState
    Selectable.animationTriggers
    Selectable.targetGraphic
    Selectable.interactable
    Selectable.image
    Selectable.animator
    Selectable.Awake()
    Selectable.OnCanvasGroupChanged()
    Selectable.IsInteractable()
    Selectable.OnDidApplyAnimationProperties()
    Selectable.OnTransformParentChanged()
    Selectable.Reset()
    Selectable.currentSelectionState
    Selectable.InstantClearState()
    Selectable.FindSelectable(Vector3)
    Selectable.FindSelectableOnLeft()
    Selectable.FindSelectableOnRight()
    Selectable.FindSelectableOnUp()
    Selectable.FindSelectableOnDown()
    Selectable.IsHighlighted()
    Selectable.IsPressed()
    Selectable.OnPointerUp(PointerEventData)
    Selectable.OnPointerEnter(PointerEventData)
    Selectable.OnPointerExit(PointerEventData)
    Selectable.Select()
    UIBehaviour.Start()
    UIBehaviour.OnDestroy()
    UIBehaviour.IsActive()
    UIBehaviour.OnRectTransformDimensionsChange()
    UIBehaviour.OnBeforeTransformParentChanged()
    UIBehaviour.OnCanvasHierarchyChanged()
    UIBehaviour.IsDestroyed()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.destroyCancellationToken
    MonoBehaviour.useGUILayout
    MonoBehaviour.didStart
    MonoBehaviour.didAwake
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.GetComponentIndex()
    Component.CompareTag(string)
    Component.CompareTag(TagHandle)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: TMPro
    Assembly: Unity.TextMeshPro.dll
    Syntax
    [AddComponentMenu("UI/TextMeshPro - Input Field", 11)]
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.textmeshpro@3.2")]
    public class TMP_InputField : Selectable, IMoveHandler, IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler, IUpdateSelectedHandler, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerClickHandler, ISubmitHandler, ICancelHandler, ICanvasElement, ILayoutElement, IScrollHandler, IEventSystemHandler

    Constructors

    TMP_InputField()

    Declaration
    protected TMP_InputField()

    Fields

    isAlert

    Determines if the keyboard is opened in alert mode.

    Declaration
    public bool isAlert
    Field Value
    Type Description
    bool

    m_CaretPosition

    Declaration
    protected int m_CaretPosition
    Field Value
    Type Description
    int

    m_CaretSelectPosition

    Declaration
    protected int m_CaretSelectPosition
    Field Value
    Type Description
    int

    m_CaretVisible

    Declaration
    protected bool m_CaretVisible
    Field Value
    Type Description
    bool

    m_CursorVerts

    Declaration
    protected UIVertex[] m_CursorVerts
    Field Value
    Type Description
    UIVertex[]

    m_GlobalFontAsset

    Declaration
    [SerializeField]
    protected TMP_FontAsset m_GlobalFontAsset
    Field Value
    Type Description
    TMP_FontAsset

    m_InputValidator

    Declaration
    [SerializeField]
    protected TMP_InputValidator m_InputValidator
    Field Value
    Type Description
    TMP_InputValidator

    m_LineLimit

    Declaration
    [SerializeField]
    protected int m_LineLimit
    Field Value
    Type Description
    int

    m_Mesh

    Declaration
    [NonSerialized]
    protected Mesh m_Mesh
    Field Value
    Type Description
    Mesh

    m_OnFocusSelectAll

    Declaration
    [SerializeField]
    protected bool m_OnFocusSelectAll
    Field Value
    Type Description
    bool

    m_Placeholder

    Declaration
    [SerializeField]
    protected Graphic m_Placeholder
    Field Value
    Type Description
    Graphic

    m_RectTransform

    Text Text used to display the input's value.

    Declaration
    protected RectTransform m_RectTransform
    Field Value
    Type Description
    RectTransform

    m_ResetOnDeActivation

    Declaration
    [SerializeField]
    protected bool m_ResetOnDeActivation
    Field Value
    Type Description
    bool

    m_ScrollSensitivity

    Declaration
    [SerializeField]
    protected float m_ScrollSensitivity
    Field Value
    Type Description
    float

    m_SoftKeyboard

    Declaration
    protected TouchScreenKeyboard m_SoftKeyboard
    Field Value
    Type Description
    TouchScreenKeyboard

    m_StringPosition

    Declaration
    protected int m_StringPosition
    Field Value
    Type Description
    int

    m_StringSelectPosition

    Declaration
    protected int m_StringSelectPosition
    Field Value
    Type Description
    int

    m_Text

    Input field's value.

    Declaration
    [SerializeField]
    [TextArea(5, 10)]
    protected string m_Text
    Field Value
    Type Description
    string

    m_TextComponent

    Declaration
    [SerializeField]
    protected TMP_Text m_TextComponent
    Field Value
    Type Description
    TMP_Text

    m_TextComponentRectMask

    Declaration
    protected RectMask2D m_TextComponentRectMask
    Field Value
    Type Description
    RectMask2D

    m_TextComponentRectTransform

    Declaration
    protected RectTransform m_TextComponentRectTransform
    Field Value
    Type Description
    RectTransform

    m_TextViewport

    Declaration
    [SerializeField]
    protected RectTransform m_TextViewport
    Field Value
    Type Description
    RectTransform

    m_TextViewportRectMask

    Declaration
    protected RectMask2D m_TextViewportRectMask
    Field Value
    Type Description
    RectMask2D

    m_VerticalScrollbar

    Declaration
    [SerializeField]
    protected Scrollbar m_VerticalScrollbar
    Field Value
    Type Description
    Scrollbar

    m_VerticalScrollbarEventHandler

    Declaration
    [SerializeField]
    protected TMP_ScrollbarEventHandler m_VerticalScrollbarEventHandler
    Field Value
    Type Description
    TMP_ScrollbarEventHandler

    m_isRichTextEditingAllowed

    Declaration
    [SerializeField]
    protected bool m_isRichTextEditingAllowed
    Field Value
    Type Description
    bool

    m_isSelectAll

    Declaration
    protected bool m_isSelectAll
    Field Value
    Type Description
    bool

    Properties

    asteriskChar

    Declaration
    public char asteriskChar { get; set; }
    Property Value
    Type Description
    char

    caretBlinkRate

    Declaration
    public float caretBlinkRate { get; set; }
    Property Value
    Type Description
    float

    caretColor

    Declaration
    public Color caretColor { get; set; }
    Property Value
    Type Description
    Color

    caretPosition

    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
    Type Description
    int

    caretPositionInternal

    Current position of the cursor. Getters are public Setters are protected

    Declaration
    protected int caretPositionInternal { get; set; }
    Property Value
    Type Description
    int

    caretSelectPositionInternal

    Declaration
    protected int caretSelectPositionInternal { get; set; }
    Property Value
    Type Description
    int

    caretWidth

    Declaration
    public int caretWidth { get; set; }
    Property Value
    Type Description
    int

    characterLimit

    Declaration
    public int characterLimit { get; set; }
    Property Value
    Type Description
    int

    characterValidation

    The type of validation to perform on a character

    Declaration
    public TMP_InputField.CharacterValidation characterValidation { get; set; }
    Property Value
    Type Description
    TMP_InputField.CharacterValidation

    contentType

    Declaration
    public TMP_InputField.ContentType contentType { get; set; }
    Property Value
    Type Description
    TMP_InputField.ContentType

    customCaretColor

    Declaration
    public bool customCaretColor { get; set; }
    Property Value
    Type Description
    bool

    flexibleHeight

    See ILayoutElement.flexibleHeight.

    Declaration
    public virtual float flexibleHeight { get; }
    Property Value
    Type Description
    float

    flexibleWidth

    See ILayoutElement.flexibleWidth.

    Declaration
    public virtual float flexibleWidth { get; }
    Property Value
    Type Description
    float

    fontAsset

    Sets the Font Asset on both Placeholder and Input child objects.

    Declaration
    public TMP_FontAsset fontAsset { get; set; }
    Property Value
    Type Description
    TMP_FontAsset

    inputType

    The type of input expected. See InputField.InputType.

    Declaration
    public TMP_InputField.InputType inputType { get; set; }
    Property Value
    Type Description
    TMP_InputField.InputType

    inputValidator

    Sets the Input Validation to use a Custom Input Validation script.

    Declaration
    public TMP_InputValidator inputValidator { get; set; }
    Property Value
    Type Description
    TMP_InputValidator

    isFocused

    Declaration
    public bool isFocused { get; }
    Property Value
    Type Description
    bool

    isRichTextEditingAllowed

    Is Rich Text editing allowed?

    Declaration
    public bool isRichTextEditingAllowed { get; set; }
    Property Value
    Type Description
    bool

    keepTextSelectionVisible

    Determines if the text selection will remain visible when the input field looses focus and is deactivated.

    Declaration
    public bool keepTextSelectionVisible { get; set; }
    Property Value
    Type Description
    bool

    keyboardType

    They type of mobile keyboard that will be used.

    Declaration
    public TouchScreenKeyboardType keyboardType { get; set; }
    Property Value
    Type Description
    TouchScreenKeyboardType

    layoutPriority

    See ILayoutElement.layoutPriority.

    Declaration
    public virtual int layoutPriority { get; }
    Property Value
    Type Description
    int

    lineLimit

    Limits the number of lines of text in the Input Field.

    Declaration
    public int lineLimit { get; set; }
    Property Value
    Type Description
    int

    lineType

    Declaration
    public TMP_InputField.LineType lineType { get; set; }
    Property Value
    Type Description
    TMP_InputField.LineType

    mesh

    Declaration
    protected Mesh mesh { get; }
    Property Value
    Type Description
    Mesh

    minHeight

    See ILayoutElement.minHeight.

    Declaration
    public virtual float minHeight { get; }
    Property Value
    Type Description
    float

    minWidth

    See ILayoutElement.minWidth.

    Declaration
    public virtual float minWidth { get; }
    Property Value
    Type Description
    float

    multiLine

    Declaration
    public bool multiLine { get; }
    Property Value
    Type Description
    bool

    onDeselect

    Declaration
    public TMP_InputField.SelectionEvent onDeselect { get; set; }
    Property Value
    Type Description
    TMP_InputField.SelectionEvent

    onEndEdit

    Declaration
    public TMP_InputField.SubmitEvent onEndEdit { get; set; }
    Property Value
    Type Description
    TMP_InputField.SubmitEvent

    onEndTextSelection

    Declaration
    public TMP_InputField.TextSelectionEvent onEndTextSelection { get; set; }
    Property Value
    Type Description
    TMP_InputField.TextSelectionEvent

    onFocusSelectAll

    Determines if the whole text will be selected when focused.

    Declaration
    public bool onFocusSelectAll { get; set; }
    Property Value
    Type Description
    bool

    onSelect

    Declaration
    public TMP_InputField.SelectionEvent onSelect { get; set; }
    Property Value
    Type Description
    TMP_InputField.SelectionEvent

    onSubmit

    Declaration
    public TMP_InputField.SubmitEvent onSubmit { get; set; }
    Property Value
    Type Description
    TMP_InputField.SubmitEvent

    onTextSelection

    Declaration
    public TMP_InputField.TextSelectionEvent onTextSelection { get; set; }
    Property Value
    Type Description
    TMP_InputField.TextSelectionEvent

    onTouchScreenKeyboardStatusChanged

    Declaration
    public TMP_InputField.TouchScreenKeyboardEvent onTouchScreenKeyboardStatusChanged { get; set; }
    Property Value
    Type Description
    TMP_InputField.TouchScreenKeyboardEvent

    onValidateInput

    Declaration
    public TMP_InputField.OnValidateInput onValidateInput { get; set; }
    Property Value
    Type Description
    TMP_InputField.OnValidateInput

    onValueChanged

    Declaration
    public TMP_InputField.OnChangeEvent onValueChanged { get; set; }
    Property Value
    Type Description
    TMP_InputField.OnChangeEvent

    placeholder

    Declaration
    public Graphic placeholder { get; set; }
    Property Value
    Type Description
    Graphic

    pointSize

    Set the point size on both Placeholder and Input text object.

    Declaration
    public float pointSize { get; set; }
    Property Value
    Type Description
    float

    preferredHeight

    Get the height of all the text if constrained to the height of the RectTransform.

    Declaration
    public virtual float preferredHeight { get; }
    Property Value
    Type Description
    float

    preferredWidth

    Get the displayed with of all input characters.

    Declaration
    public virtual float preferredWidth { get; }
    Property Value
    Type Description
    float

    readOnly

    Declaration
    public bool readOnly { get; set; }
    Property Value
    Type Description
    bool

    resetOnDeActivation

    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
    Type Description
    bool

    restoreOriginalTextOnEscape

    Controls whether the original text is restored when pressing "ESC".

    Declaration
    public bool restoreOriginalTextOnEscape { get; set; }
    Property Value
    Type Description
    bool

    richText

    Declaration
    public bool richText { get; set; }
    Property Value
    Type Description
    bool

    scrollSensitivity

    Declaration
    public float scrollSensitivity { get; set; }
    Property Value
    Type Description
    float

    selectionAnchorPosition

    Get: Returns the fixed position of selection Set: If compositionString is 0 set the fixed position

    Declaration
    public int selectionAnchorPosition { get; set; }
    Property Value
    Type Description
    int

    selectionColor

    Declaration
    public Color selectionColor { get; set; }
    Property Value
    Type Description
    Color

    selectionFocusPosition

    Get: Returns the variable position of selection Set: If compositionString is 0 set the variable position

    Declaration
    public int selectionFocusPosition { get; set; }
    Property Value
    Type Description
    int

    selectionStringAnchorPosition

    The fixed position of the selection in the raw string which may contains rich text.

    Declaration
    public int selectionStringAnchorPosition { get; set; }
    Property Value
    Type Description
    int

    selectionStringFocusPosition

    The variable position of the selection in the raw string which may contains rich text.

    Declaration
    public int selectionStringFocusPosition { get; set; }
    Property Value
    Type Description
    int

    shouldActivateOnSelect

    Should the inputfield be automatically activated upon selection.

    Declaration
    public virtual bool shouldActivateOnSelect { get; set; }
    Property Value
    Type Description
    bool

    shouldHideMobileInput

    Should the mobile keyboard input be hidden.

    Declaration
    public bool shouldHideMobileInput { get; set; }
    Property Value
    Type Description
    bool

    shouldHideSoftKeyboard

    Declaration
    public bool shouldHideSoftKeyboard { get; set; }
    Property Value
    Type Description
    bool

    stringPosition

    Declaration
    public int stringPosition { get; set; }
    Property Value
    Type Description
    int

    stringPositionInternal

    Declaration
    protected int stringPositionInternal { get; set; }
    Property Value
    Type Description
    int

    stringSelectPositionInternal

    Declaration
    protected int stringSelectPositionInternal { get; set; }
    Property Value
    Type Description
    int

    text

    Input field's current text value. This is not necessarily the same as what is visible on screen.

    Declaration
    public string text { get; set; }
    Property Value
    Type Description
    string
    Remarks

    Note that null is invalid value for InputField.text.

    Examples
    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI; // Required when Using UI elements.
    
    public class Example : MonoBehaviour
    {
        public InputField mainInputField;
    
        public void Start()
        {
            mainInputField.text = "Enter Text Here...";
        }
    }

    textComponent

    Declaration
    public TMP_Text textComponent { get; set; }
    Property Value
    Type Description
    TMP_Text

    textViewport

    Declaration
    public RectTransform textViewport { get; set; }
    Property Value
    Type Description
    RectTransform

    touchScreenKeyboard

    The TouchScreenKeyboard being used to edit the Input Field.

    Declaration
    public TouchScreenKeyboard touchScreenKeyboard { get; }
    Property Value
    Type Description
    TouchScreenKeyboard

    verticalScrollbar

    Declaration
    public Scrollbar verticalScrollbar { get; set; }
    Property Value
    Type Description
    Scrollbar

    wasCanceled

    Declaration
    public bool wasCanceled { get; }
    Property Value
    Type Description
    bool

    Methods

    ActivateInputField()

    Declaration
    public void ActivateInputField()

    Append(char)

    Declaration
    protected virtual void Append(char input)
    Parameters
    Type Name Description
    char input

    Append(string)

    Append the specified text to the end of the current.

    Declaration
    protected virtual void Append(string input)
    Parameters
    Type Name Description
    string input

    CalculateLayoutInputHorizontal()

    See ILayoutElement.CalculateLayoutInputHorizontal.

    Declaration
    public virtual void CalculateLayoutInputHorizontal()

    CalculateLayoutInputVertical()

    See ILayoutElement.CalculateLayoutInputVertical.

    Declaration
    public virtual void CalculateLayoutInputVertical()

    ClampCaretPos(ref int)

    Declaration
    protected void ClampCaretPos(ref int pos)
    Parameters
    Type Name Description
    int pos

    ClampStringPos(ref int)

    Declaration
    protected void ClampStringPos(ref int pos)
    Parameters
    Type Name Description
    int pos

    DeactivateInputField(bool)

    Declaration
    public void DeactivateInputField(bool clearSelection = false)
    Parameters
    Type Name Description
    bool clearSelection

    DoStateTransition(SelectionState, bool)

    Transition the Selectable to the entered state.

    Declaration
    protected override void DoStateTransition(Selectable.SelectionState state, bool instant)
    Parameters
    Type Name Description
    Selectable.SelectionState state

    State to transition to

    bool instant

    Should the transition occur instantly.

    Overrides
    Selectable.DoStateTransition(Selectable.SelectionState, bool)

    ForceLabelUpdate()

    Declaration
    public void ForceLabelUpdate()

    GraphicUpdateComplete()

    Callback sent when this ICanvasElement has completed Graphic rebuild.

    Declaration
    public virtual void GraphicUpdateComplete()

    IsValidChar(char)

    Declaration
    protected virtual bool IsValidChar(char c)
    Parameters
    Type Name Description
    char c
    Returns
    Type Description
    bool

    KeyPressed(Event)

    Declaration
    protected TMP_InputField.EditState KeyPressed(Event evt)
    Parameters
    Type Name Description
    Event evt
    Returns
    Type Description
    TMP_InputField.EditState

    LateUpdate()

    Update the text based on input.

    Declaration
    protected virtual void LateUpdate()

    LayoutComplete()

    Callback sent when this ICanvasElement has completed layout.

    Declaration
    public virtual void LayoutComplete()

    MoveTextEnd(bool)

    Move to the end of the text.

    Declaration
    public void MoveTextEnd(bool shift)
    Parameters
    Type Name Description
    bool shift

    MoveTextStart(bool)

    Move to the start of the text.

    Declaration
    public void MoveTextStart(bool shift)
    Parameters
    Type Name Description
    bool shift

    MoveToEndOfLine(bool, bool)

    Move to the end of the current line of text.

    Declaration
    public void MoveToEndOfLine(bool shift, bool ctrl)
    Parameters
    Type Name Description
    bool shift
    bool ctrl

    MoveToStartOfLine(bool, bool)

    Move to the start of the current line of text.

    Declaration
    public void MoveToStartOfLine(bool shift, bool ctrl)
    Parameters
    Type Name Description
    bool shift
    bool ctrl

    OnBeginDrag(PointerEventData)

    Called by a BaseInputModule before a drag is started.

    Declaration
    public virtual void OnBeginDrag(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData

    OnCancel(BaseEventData)

    Declaration
    public virtual void OnCancel(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData

    OnControlClick()

    Declaration
    public void OnControlClick()

    OnDeselect(BaseEventData)

    Unset selection and transition to appropriate state.

    Declaration
    public override void OnDeselect(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData
    Overrides
    Selectable.OnDeselect(BaseEventData)
    Examples
      using UnityEngine;
                            using System.Collections;
                            using UnityEngine.UI;
                            using UnityEngine.EventSystems;// Required when using Event data.
    
                            public class ExampleClass : MonoBehaviour, IDeselectHandler //This Interface is required to receive OnDeselect callbacks.
                            {
                                public void OnDeselect(BaseEventData data)
                                {
                                    Debug.Log("Deselected");
                                }
                            }
    

    OnDisable()

    Declaration
    protected override void OnDisable()
    Overrides
    Selectable.OnDisable()

    OnDrag(PointerEventData)

    When dragging is occurring this will be called every time the cursor is moved.

    Declaration
    public virtual void OnDrag(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData

    OnEnable()

    Declaration
    protected override void OnEnable()
    Overrides
    Selectable.OnEnable()

    OnEndDrag(PointerEventData)

    Called by a BaseInputModule when a drag is ended.

    Declaration
    public virtual void OnEndDrag(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData

    OnFocus()

    Declaration
    protected void OnFocus()

    OnMove(AxisEventData)

    Determine in which of the 4 move directions the next selectable object should be found.

    Declaration
    public override void OnMove(AxisEventData eventData)
    Parameters
    Type Name Description
    AxisEventData eventData
    Overrides
    Selectable.OnMove(AxisEventData)
    Examples
      using UnityEngine;
                            using System.Collections;
                            using UnityEngine.UI;
                            using UnityEngine.EventSystems;// Required when using Event data.
    
                            public class ExampleClass : MonoBehaviour, IMoveHandler
                            {
                                //When the focus moves to another selectable object, Invoke this Method.
                                public void OnMove(AxisEventData eventData)
                                {
                                    //Assigns the move direction and the raw input vector representing the direction from the event data.
                                    MoveDirection moveDir = eventData.moveDir;
                                    Vector2 moveVector = eventData.moveVector;
    
                                    //Displays the information in the console
                                    Debug.Log(moveDir + ", " + moveVector);
                                }
                            }
    

    OnPointerClick(PointerEventData)

    Use this callback to detect clicks.

    Declaration
    public virtual void OnPointerClick(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData

    OnPointerDown(PointerEventData)

    Evaluate current state and transition to pressed state.

    Declaration
    public override void OnPointerDown(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData
    Overrides
    Selectable.OnPointerDown(PointerEventData)
    Examples
      using UnityEngine;
                            using System.Collections;
                            using UnityEngine.UI;
                            using UnityEngine.EventSystems;// Required when using Event data.
    
                            public class ExampleClass : MonoBehaviour, IPointerDownHandler// required interface when using the OnPointerDown method.
                            {
                                //Do this when the mouse is clicked over the selectable object this script is attached to.
                                public void OnPointerDown(PointerEventData eventData)
                                {
                                    Debug.Log(this.gameObject.name + " Was Clicked.");
                                }
                            }
    

    OnScroll(PointerEventData)

    Declaration
    public virtual void OnScroll(PointerEventData eventData)
    Parameters
    Type Name Description
    PointerEventData eventData

    OnSelect(BaseEventData)

    Set selection and transition to appropriate state.

    Declaration
    public override void OnSelect(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData
    Overrides
    Selectable.OnSelect(BaseEventData)
    Examples
      using UnityEngine;
                            using System.Collections;
                            using UnityEngine.UI;
                            using UnityEngine.EventSystems;// Required when using Event data.
    
                            public class ExampleClass : MonoBehaviour, ISelectHandler// required interface when using the OnSelect method.
                            {
                                //Do this when the selectable UI object is selected.
                                public void OnSelect(BaseEventData eventData)
                                {
                                    Debug.Log(this.gameObject.name + " was selected");
                                }
                            }
    

    OnSubmit(BaseEventData)

    Declaration
    public virtual void OnSubmit(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData

    OnUpdateSelected(BaseEventData)

    Declaration
    public virtual void OnUpdateSelected(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData

    OnValidate()

    Declaration
    protected override void OnValidate()
    Overrides
    Selectable.OnValidate()

    ProcessEvent(Event)

    Declaration
    public void ProcessEvent(Event e)
    Parameters
    Type Name Description
    Event e

    Rebuild(CanvasUpdate)

    Rebuild the element for the given stage.

    Declaration
    public virtual void Rebuild(CanvasUpdate update)
    Parameters
    Type Name Description
    CanvasUpdate update

    ReleaseSelection()

    Declaration
    public void ReleaseSelection()

    SelectAll()

    Declaration
    protected void SelectAll()

    SendOnEndEdit()

    Submit the input field's text.

    Declaration
    protected void SendOnEndEdit()

    SendOnEndTextSelection()

    Declaration
    protected void SendOnEndTextSelection()

    SendOnFocus()

    Declaration
    protected void SendOnFocus()

    SendOnFocusLost()

    Declaration
    protected void SendOnFocusLost()

    SendOnSubmit()

    Declaration
    protected void SendOnSubmit()

    SendOnTextSelection()

    Declaration
    protected void SendOnTextSelection()

    SendTouchScreenKeyboardStatusChanged()

    Declaration
    protected void SendTouchScreenKeyboardStatusChanged()

    SetGlobalFontAsset(TMP_FontAsset)

    Function to conveniently set the Font Asset of both Placeholder and Input Field text object.

    Declaration
    public void SetGlobalFontAsset(TMP_FontAsset fontAsset)
    Parameters
    Type Name Description
    TMP_FontAsset fontAsset

    SetGlobalPointSize(float)

    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
    float pointSize

    SetTextWithoutNotify(string)

    Set Input field's current text value without invoke onValueChanged. This is not necessarily the same as what is visible on screen.

    Declaration
    public void SetTextWithoutNotify(string input)
    Parameters
    Type Name Description
    string input

    UpdateLabel()

    Update the visual text Text.

    Declaration
    protected void UpdateLabel()

    Validate(string, int, char)

    Validate the specified input.

    Declaration
    protected char Validate(string text, int pos, char ch)
    Parameters
    Type Name Description
    string text
    int pos
    char ch
    Returns
    Type Description
    char

    Implements

    IMoveHandler
    IPointerDownHandler
    IPointerUpHandler
    IPointerEnterHandler
    IPointerExitHandler
    ISelectHandler
    IDeselectHandler
    IUpdateSelectedHandler
    IBeginDragHandler
    IDragHandler
    IEndDragHandler
    IPointerClickHandler
    ISubmitHandler
    ICancelHandler
    ICanvasElement
    ILayoutElement
    IScrollHandler
    IEventSystemHandler
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)