コード例 #1
0
    void Update()
    {
        if (EventSystem.current.currentSelectedGameObject)
        {
            TMP_InputField input = EventSystem.current.currentSelectedGameObject.GetComponent <TMP_InputField>();
            if (input != null)
            {
                if (targetedInputFields.Contains(input.GetHashCode()))
                {
                    activeField = input;

                    //Debug.Log(activeField.isFocused + " " + activeField.caretPosition);
                    if (activeField.isFocused)
                    {
                        //Debug.Log(activeField.selectionFocusPosition);
                        //Debug.Log(activeField.caretWidth);
                        //Debug.Log(activeField.selectionAnchorPosition);
                        caretPosition  = activeField.caretPosition;
                        anchorPosition = activeField.selectionAnchorPosition;
                    }
                    //Debug.Log(activeField.caretPosition);
                    ColorActiveInputField();
                }
                else
                {
                    // clicked on not a targeted input field.
                }
            }
            else
            {
                for (int i = 0; i < inputFields.Length; ++i)
                {
                    //inputFields[i].interactable = true;
                }
            }
        }
    }