#if UIWIDGETS_TMPRO_SUPPORT && (UNITY_5_2 || UNITY_5_3 || UNITY_5_3_OR_NEWER) namespace UIWidgets { using System; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; /// /// Proxy for TMP_InputField. /// public class InputFieldTMProProxy : IInputFieldProxy { /// /// The InputField. /// readonly TMP_InputField inputField; /// /// Initializes a new instance of the class. /// /// Input. public InputFieldTMProProxy(TMP_InputField input) { inputField = input; } #region IInputFieldProxy implementation /// /// The current value of the input field. /// /// The text. public string text { get { return inputField.text; } set { inputField.text = value; } } /// /// The Unity Event to call when edit. /// /// The OnValueChange. public UnityEvent onValueChanged { get { #if UNITY_5_3 || UNITY_5_3_OR_NEWER return inputField.onValueChanged; #else return inputField.onValueChange; #endif } } /// /// The Unity Event to call when editing has ended. /// /// The OnEndEdit. public UnityEvent onEndEdit { get { return inputField.onEndEdit; } } /// /// Current InputField caret position (also selection tail). /// /// The caret position. public int caretPosition { get { #if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_3_OR_NEWER return inputField.caretPosition; #else return inputField.text.Length; #endif } set { #if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_3_OR_NEWER inputField.caretPosition = value; #else // inputField.ActivateInputField(); #endif } } /// /// Is the InputField eligible for interaction (excludes canvas groups). /// /// true /// false public bool interactable { get { return inputField.interactable; } set { inputField.interactable = value; } } /// /// Determines whether InputField instance is null. /// /// true /// false public bool IsNull() { return inputField == null; } /// /// Gets the gameobject. /// /// The gameobject. public GameObject gameObject { get { return (inputField != null) ? inputField.gameObject : null; } } /// /// Text component. /// public Graphic textComponent { get { return inputField.textComponent; } set { inputField.textComponent = value as TMP_Text; } } /// /// Placeholder. /// public Graphic placeholder { get { return inputField.placeholder; } set { inputField.placeholder = value; } } /// /// If the proxy was canceled and will revert back to the original text. /// public bool wasCanceled { get { return inputField.wasCanceled; } } /// /// Determines whether this lineType is LineType.MultiLineNewline. /// /// true /// false public bool IsMultiLineNewline() { return inputField.lineType == TMP_InputField.LineType.MultiLineNewline; } /// /// Function to activate the InputField to begin processing Events. /// public void ActivateInputField() { inputField.ActivateInputField(); } /// /// Set focus to InputField. /// public void Focus() { ActivateInputField(); inputField.Select(); } /// /// Set focus to InputField. /// public void Select() { ActivateInputField(); inputField.Select(); } #endregion } } #endif