示例#1
0
        protected override void Awake()
        {
            m_InputOverride = GetComponent <BaseInput>();

            base.Awake();

            if (m_inputProvider == null)
            {
                m_inputProvider = GetComponent <InputProvider>();
            }
        }
示例#2
0
        protected override void OnEventSystemUpdate()
        {
            base.OnEventSystemUpdate();

            InputModule inputModule = EventSystem.currentInputModule as InputModule;

            if (inputModule != null && inputModule.InputProvider != null)
            {
                InputProvider input = inputModule.InputProvider;

                if (input.IsMouseButtonDown(0))
                {
                    // if (IsSelected(m_inputField.gameObject))

                    //IsEditing = true;
                    // m_activateOnEventSystemLateUpdate = true;



                    return;
                }

                if (input.IsSubmitButtonDown)
                {
                    if (IsSelected(m_inputField.gameObject))
                    {
                        if (IsEditing)
                        {
                            if (!VirtualKeyboardEnabled)
                            {
                                IsEditing = false;
                                m_inputField.DeactivateInputField();
                            }
                        }
                        else
                        {
                            IsEditing = true;
                            m_activateOnEventSystemLateUpdate = true;
                        }
                    }

                    return;
                }

                if (input.IsCancelButtonDown)
                {
                    if (IsEditing && IsSelected(m_inputField.gameObject))
                    {
                        m_inputField.text = m_text;
                        m_inputField.DeactivateInputField();
                    }
                    return;
                }

                if (input.IsFunctional2ButtonDown && IsEditing)
                {
                    if (m_enterKey != null)
                    {
                        m_enterKey.OnSubmit(null);
                        m_enterKey.OnEndSubmit(null);
                    }

                    return;
                }

                float h = input.HorizontalAxis2;
                if (h > 0.5 || h > 0 && input.IsHorizontal2ButtonDown)
                {
                    h = 1;
                }
                else if (h < -0.5 || h < 0 && input.IsHorizontal2ButtonDown)
                {
                    h = -1;
                }
                else
                {
                    h = 0;
                }

                if (!Mathf.Approximately(h, 0))
                {
                    if (m_repeatT < Time.time)
                    {
                        if (input.IsHorizontal2ButtonDown)
                        {
                            m_repeatT = Time.time + m_repeatDelay * 3;
                        }
                        else
                        {
                            m_repeatT = Time.time + m_repeatDelay;
                        }

                        if (h > 0)
                        {
                            if (input.IsFunctionalButtonPressed)
                            {
                                m_inputField.selectionFocusPosition++;
                            }
                            else
                            {
                                if (m_inputField.selectionAnchorPosition != m_inputField.selectionFocusPosition)
                                {
                                    m_inputField.caretPosition =
                                        m_inputField.selectionFocusPosition > m_inputField.selectionAnchorPosition ?
                                        m_inputField.selectionFocusPosition :
                                        m_inputField.selectionAnchorPosition;
                                }
                                else
                                {
                                    m_inputField.caretPosition++;
                                }
                            }
                            m_inputField.ForceLabelUpdate();
                        }
                        else if (h < 0)
                        {
                            if (input.IsFunctionalButtonPressed)
                            {
                                m_inputField.selectionFocusPosition--;
                            }
                            else
                            {
                                if (m_inputField.selectionAnchorPosition != m_inputField.selectionFocusPosition)
                                {
                                    m_inputField.caretPosition = m_inputField.selectionFocusPosition < m_inputField.selectionAnchorPosition ?
                                                                 m_inputField.selectionFocusPosition :
                                                                 m_inputField.selectionAnchorPosition;
                                }
                                else
                                {
                                    m_inputField.caretPosition--;
                                }
                            }
                            m_inputField.ForceLabelUpdate();
                        }
                    }
                }
            }
        }