예제 #1
0
        public void OnMove(AxisEventData eventData)
        {
            int nTemp      = (1 << (int)EventTriggerType.Move);
            int nEventMask = (int)this.EventTypeMask;

            if ((nEventMask & nTemp) == nTemp)
            {
                this.Handle(eventData, EventTriggerType.Move);
            }
        }
예제 #2
0
        public override void OnMove(AxisEventData eventData)
        {
            if (!IsActive() || !IsInteractable())
            {
                base.OnMove(eventData);
                return;
            }

            switch (eventData.moveDir)
            {
            case MoveDirection.Left:
                if (axis == Axis.Horizontal && FindSelectableOnLeft() == null)
                {
                    Set(reverseValue ? value + stepSize : value - stepSize);
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;

            case MoveDirection.Right:
                if (axis == Axis.Horizontal && FindSelectableOnRight() == null)
                {
                    Set(reverseValue ? value - stepSize : value + stepSize);
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;

            case MoveDirection.Up:
                if (axis == Axis.Vertical && FindSelectableOnUp() == null)
                {
                    Set(reverseValue ? value - stepSize : value + stepSize);
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;

            case MoveDirection.Down:
                if (axis == Axis.Vertical && FindSelectableOnDown() == null)
                {
                    Set(reverseValue ? value + stepSize : value - stepSize);
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;
            }
        }
예제 #3
0
        /// <summary>
        /// Raises the move event.
        /// </summary>
        /// <param name="eventData">Event data.</param>
        public override void OnMove(AxisEventData eventData)
        {
            if (!IsActive() || !IsInteractable())
            {
                base.OnMove(eventData);
                return;
            }

            switch (eventData.moveDir)
            {
            case MoveDirection.Left:
                if (IsHorizontal() && FindSelectableOnLeft() == null)
                {
                    Decrease();
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;

            case MoveDirection.Right:
                if (IsHorizontal() && FindSelectableOnRight() == null)
                {
                    Increase();
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;

            case MoveDirection.Up:
                if (!IsHorizontal() && FindSelectableOnUp() == null)
                {
                    Increase();
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;

            case MoveDirection.Down:
                if (!IsHorizontal() && FindSelectableOnDown() == null)
                {
                    Decrease();
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;
            }
        }
예제 #4
0
 public void OnMove(AxisEventData eventData)
 {
     if (onEventMove != null)
     {
         onEventMove(eventData);
     }
     if (onMove != null)
     {
         onMove(gameObject);
     }
 }
예제 #5
0
 protected AxisEventData GetAxisEventData(float x, float y, float moveDeadZone)
 {
     if (this._axisEventData == null)
     {
         this._axisEventData = new AxisEventData(EventSystem.get_current());
     }
     ((AbstractEventData)this._axisEventData).Reset();
     this._axisEventData.set_moveVector(new Vector2(x, y));
     this._axisEventData.set_moveDir(Input.DetermineMoveDirection(x, y, moveDeadZone));
     return(this._axisEventData);
 }
예제 #6
0
 public void OnMove(AxisEventData eventData)
 {
     if (isTopButtonInMenu == true && eventData.moveVector.y > 0)
     {
         dialRotateHandler.CheckIfDialTransformRotateNeeded(+1);
     }
     if (isBottomButtonInMenu == true && eventData.moveVector.y < 0)
     {
         dialRotateHandler.CheckIfDialTransformRotateNeeded(-1);
     }
 }
예제 #7
0
 public override void OnMove(AxisEventData eventData)
 {
     if (OverrideNavigation)
     {
         OnNavigate.Invoke(eventData);
     }
     else
     {
         DoMove(eventData);
     }
 }
예제 #8
0
 public override void OnMove(AxisEventData eventData)
 {
     if (this.onMove != null)
     {
         this.onMove.Call(new object[]
         {
             base.gameObject,
             eventData.moveVector
         });
     }
 }
예제 #9
0
        /// <summary>
        /// OnUpdateSelected event.
        /// </summary>
        /// <param name="eventData">Event data.</param>
        public virtual void OnUpdateSelected(BaseEventData eventData)
        {
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                var axisEvent = new AxisEventData(EventSystem.current)
                {
                    moveDir = MoveDirection.Left,
                };
                OnMoveEvent.Invoke(axisEvent);
                return;
            }

            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                var axisEvent = new AxisEventData(EventSystem.current)
                {
                    moveDir = MoveDirection.Right,
                };
                OnMoveEvent.Invoke(axisEvent);
                return;
            }

            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                var axisEvent = new AxisEventData(EventSystem.current)
                {
                    moveDir = MoveDirection.Up,
                };
                OnMoveEvent.Invoke(axisEvent);
                return;
            }

            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                var axisEvent = new AxisEventData(EventSystem.current)
                {
                    moveDir = MoveDirection.Down,
                };
                OnMoveEvent.Invoke(axisEvent);
                return;
            }

            if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
            {
                var isEnter = Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter);
                var isShift = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
                if (!(isEnter && isShift))
                {
                    OnSubmitEvent.Invoke(eventData, isEnter);
                }

                return;
            }
        }
예제 #10
0
        private static void MoveSelection(MoveDirection dir)
        {
            EventSystem   eventSystem = EventSystem.current;
            AxisEventData data        = new AxisEventData(eventSystem)
            {
                moveDir        = dir,
                selectedObject = eventSystem.currentSelectedGameObject,
            };

            ExecuteEvents.Execute(data.selectedObject, data, ExecuteEvents.moveHandler);
        }
    /// <summary>
    /// Hack-y solution to allow navigation of multiple UI's with one EventSystem
    /// Works for both navigating between objects and setting values on sliders
    /// </summary>
    /// <param name="direction">Direction to send to the UI navigation system</param>
    private void NavigateMenu(MoveDirection direction)
    {
        eventSystem.SetSelectedGameObject(currentSelected);
        AxisEventData axisData = new AxisEventData(eventSystem);

        axisData.moveDir = direction;
        ExecuteEvents.Execute(currentSelected, axisData, ExecuteEvents.moveHandler);
        currentSelected = eventSystem.currentSelectedGameObject;
        CheckForSelectedOutOfBounds();
        ScrollToActive();
    }
예제 #12
0
파일: CSlider.cs 프로젝트: gsoec/lm-source
        // Token: 0x060029BC RID: 10684 RVA: 0x0045B990 File Offset: 0x00459B90
        public override void OnMove(AxisEventData eventData)
        {
            if (!this.IsActive() || !this.IsInteractable())
            {
                base.OnMove(eventData);
                return;
            }
            switch (eventData.moveDir)
            {
            case MoveDirection.Left:
                if (this.axis == CSlider.Axis.Horizontal && this.FindSelectableOnLeft() == null)
                {
                    this.Set((!this.reverseValue) ? (this.value - this.stepSize) : (this.value + this.stepSize));
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;

            case MoveDirection.Up:
                if (this.axis == CSlider.Axis.Vertical && this.FindSelectableOnUp() == null)
                {
                    this.Set((!this.reverseValue) ? (this.value + this.stepSize) : (this.value - this.stepSize));
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;

            case MoveDirection.Right:
                if (this.axis == CSlider.Axis.Horizontal && this.FindSelectableOnRight() == null)
                {
                    this.Set((!this.reverseValue) ? (this.value + this.stepSize) : (this.value - this.stepSize));
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;

            case MoveDirection.Down:
                if (this.axis == CSlider.Axis.Vertical && this.FindSelectableOnDown() == null)
                {
                    this.Set((!this.reverseValue) ? (this.value - this.stepSize) : (this.value + this.stepSize));
                }
                else
                {
                    base.OnMove(eventData);
                }
                break;
            }
        }
예제 #13
0
 //キー移動でSE鳴らす
 public void OnMove(AxisEventData eventData)
 {
     if (eventData.selectedObject == this.gameObject)
     {
         return;
     }
     if (highlited != null)
     {
         AudioSource.PlayClipAtPoint(highlited, Vector3.zero);
     }
 }
예제 #14
0
 private void OnEnable()
 {
     if (defaultButtonObj != null)
     {
         EventSystem.current.SetSelectedGameObject(defaultButtonObj);
         currentButton       = EventSystem.current.currentSelectedGameObject;
         currentAxis         = new AxisEventData(EventSystem.current);
         currentAxis.moveDir = MoveDirection.None;
         ExecuteEvents.Execute(currentButton, currentAxis, ExecuteEvents.moveHandler);
     }
 }
예제 #15
0
 private void OnSecondaryNavigate(float obj)
 {
     if (_navigationEnabled)
     {
         AxisEventData axisEventData = new AxisEventData(eventSystem: EventSystem.current);
         MoveDirection moveDir       = obj > 0 ? MoveDirection.Right : MoveDirection.Left;
         axisEventData.moveDir    = moveDir;
         axisEventData.moveVector = Vector2.right * obj;
         _currentlySelected.OnMove(eventData: axisEventData);
     }
 }
예제 #16
0
        /// <summary>
        /// Called once every frame while InputModule is active.
        /// </summary>
        public override void Process()
        {
            if (!eventSystem)
            {
                return;
            }
            GameObject target = eventSystem.currentSelectedGameObject;

            bool submit = Input.GetButtonDown(_submitKeyboard);
            bool cancel = Input.GetButtonDown(_cancelKeyboard);

            float x     = Input.GetAxisRaw(_horizontalKeyboard);
            float y     = Input.GetAxisRaw(_verticalKeyboard);
            var   count = 1;

            foreach (InputDevice device in HInput.Devices)
            {
                if (device == null)
                {
                    continue;
                }
                x      += device.GetControl(_horizontalGamepad);
                y      += device.GetControl(_verticalGamepad);
                submit |= device.GetControl(_submitGamepad).WasPressed;
                cancel |= device.GetControl(_cancelGamepad).WasPressed;
                count++;
            }

            if (submit)
            {
                ExecuteEvents.Execute(target, GetBaseEventData(), ExecuteEvents.submitHandler);
            }
            if (cancel)
            {
                ExecuteEvents.Execute(target, GetBaseEventData(), ExecuteEvents.cancelHandler);
            }

            currentDelay -= Time.deltaTime;
            if (!eventSystem.sendNavigationEvents || currentDelay >= 0)
            {
                return;
            }

            x /= count;
            y /= count;
            AxisEventData moveData = GetAxisEventData(x, y, _deadZone);

            ExecuteEvents.Execute(target, moveData, ExecuteEvents.moveHandler);
            if (moveData.moveDir != MoveDirection.None)
            {
                currentDelay = _navigationDelay;
            }
        }
예제 #17
0
        public override void OnMove(AxisEventData eventData)
        {
            if (!gameObject.activeSelf)
            {
                return;
            }

            if (onMove != null)
            {
                onMove(gameObject, eventData);
            }
        }
 // ----------------
 override public void OnMove(AxisEventData data)
 {
     if ((data.moveDir == MoveDirection.Left) || (data.moveDir == MoveDirection.Right))
     {
         this.OnSwitch((data.moveDir == MoveDirection.Left) ? -1 : 1);
         data.Use();
     }
     else
     {
         base.OnMove(data);
     }
 }
예제 #19
0
        private AxisEventData GetOrCreateCachedAxisEvent()
        {
            var result = m_CachedAxisEvent;

            if (result == null)
            {
                result            = new AxisEventData(eventSystem);
                m_CachedAxisEvent = result;
            }

            return(result);
        }
예제 #20
0
 public override void OnMove(AxisEventData eventData)
 {
     base.OnMove(eventData);
     if (eventData.moveDir == MoveDirection.Left)
     {
         PrevValue();
     }
     if (eventData.moveDir == MoveDirection.Right)
     {
         NextValue();
     }
 }
예제 #21
0
        protected virtual AxisEventData GetAxisEventData(float x, float y, float moveDeadZone)
        {
            if (m_AxisEventData == null)
            {
                m_AxisEventData = new AxisEventData(eventSystem);
            }

            m_AxisEventData.Reset();
            m_AxisEventData.moveVector = new Vector2(x, y);
            m_AxisEventData.moveDir    = DetermineMoveDirection(x, y, moveDeadZone);
            return(m_AxisEventData);
        }
예제 #22
0
        // sends navigation event within a canvas
        private static bool SendMoveEventToSelectedObject(AxisEventData axisEventData, EventSystem eventSystem, BaseEventData data)
        {
            // eventSystem must have a selected object
            if (eventSystem.currentSelectedGameObject == null)
            {
                return(false);
            }

            ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisEventData, ExecuteEvents.moveHandler);

            return(axisEventData.used);
        }
예제 #23
0
        protected bool SendMoveEventToSelectedObject()
        {
            float   time     = Time.unscaledTime;
            Vector2 movement = GetRawMoveVector();

            if (Mathf.Approximately(movement.x, 0f) && Mathf.Approximately(movement.y, 0f))
            {
                m_ConsecutiveMoveCount = 0;
                return(false);
            }

            bool allow      = input.GetButtonDown(m_HorizontalAxis) || input.GetButtonDown(m_VerticalAxis);
            bool similarDir = (Vector2.Dot(movement, m_LastMoveVector) > 0);

            if (!allow)
            {
                if (similarDir && m_ConsecutiveMoveCount == 1)
                {
                    allow = time > (m_PrevActionTime + m_RepeatDelay);
                }
                else
                {
                    allow = time > (m_PrevActionTime + 1f / m_InputActionsPerSecond);
                }
            }

            if (!allow)
            {
                return(false);
            }


            AxisEventData axisEventData = GetAxisEventData(movement.x, movement.y, 0.6f);

            if (axisEventData.moveDir != MoveDirection.None)
            {
                ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisEventData, ExecuteEvents.moveHandler);
                if (!similarDir)
                {
                    m_ConsecutiveMoveCount = 0;
                }
                m_ConsecutiveMoveCount++;
                m_PrevActionTime = time;
                m_LastMoveVector = movement;
            }
            else
            {
                m_ConsecutiveMoveCount = 0;
            }

            return(axisEventData.used);
        }
예제 #24
0
    public void OnMove(AxisEventData eventData)
    {
        EventSystemGame.current.PlaySound("Swap");

        /*
         * if (eventData.moveVector.y < 0)
         *  EventSystemGame.current.PlaySound("SwapDown");
         * else
         * {
         *  EventSystemGame.current.PlaySound("SwapUp");
         * }
         */
    }
예제 #25
0
    void IMoveHandler.OnMove(AxisEventData eventData)
    {
        if (onMoveCallBack != null)
        {
            onMoveCallBack();
        }

        if (onMove != null)
        {
            data = new UGUIData(gameObject, eventData, parameter);
            onMove(ref data);
        }
    }
    public override void OnMove(AxisEventData eventData)
    {
        switch (eventData.moveDir)
        {
        case MoveDirection.Left:
            menuNav.SelectPreviousItem();
            break;

        case MoveDirection.Right:
            menuNav.SelectNextItem();
            break;
        }
    }
예제 #27
0
    public void OnMove(AxisEventData eventData)
    {
        switch (eventData.moveDir)
        {
        case MoveDirection.Left:
            leftEvent.Invoke();
            break;

        case MoveDirection.Right:
            rightEvent.Invoke();
            break;
        }
    }
예제 #28
0
        public void OnMove(AxisEventData eventData)
        {
            curEventData = eventData;

            if (luaOnMove != null)
            {
                luaOnMove();
            }
            else
            {
                Debug.LogWarningFormat("OnMove but not find lua OnMove fun !");
            }
        }
        /// <summary>
        /// Selects the result.
        /// </summary>
        /// <param name="eventData">Event data.</param>
        protected virtual void SelectResult(AxisEventData eventData)
        {
            if (!DisplayListView.gameObject.activeInHierarchy)
            {
                return;
            }

            if (DisplayListView.DataSource.Count == 0)
            {
                return;
            }

            switch (eventData.moveDir)
            {
            case MoveDirection.Up:
                if (DisplayListView.SelectedIndex == 0)
                {
                    DisplayListView.SelectedIndex = DisplayListView.DataSource.Count - 1;
                }
                else
                {
                    DisplayListView.SelectedIndex -= 1;
                }

                DisplayListView.ScrollTo(DisplayListView.SelectedIndex);
                InputFieldProxy.caretPosition = CaretPosition;
                break;

            case MoveDirection.Down:
                if (DisplayListView.SelectedIndex == (DisplayListView.DataSource.Count - 1))
                {
                    DisplayListView.SelectedIndex = 0;
                }
                else
                {
                    DisplayListView.SelectedIndex += 1;
                }

                DisplayListView.ScrollTo(DisplayListView.SelectedIndex);
                InputFieldProxy.caretPosition = CaretPosition;
                break;

            default:
                if (Input2Query(InputFieldProxy.text) != Query)
                {
                    ApplyFilter(InputFieldProxy.text);
                }

                break;
            }
        }
예제 #30
0
    void Update()
    {
        if (EventSystem.current != null)
        {
            m_AxisEventData = new AxisEventData(EventSystem.current);

            if (Mapper.jInputOnUp && UGUIOperationInvalid != true ||
                Mapper.jInputOnUp2p && UGUIOperationInvalid2p != true ||
                Mapper.jInputOnUp3p && UGUIOperationInvalid3p != true ||
                Mapper.jInputOnUp4p && UGUIOperationInvalid4p != true)
            {
                UGUIUpMove();
            }
            if (Mapper.jInputOnDown && UGUIOperationInvalid != true ||
                Mapper.jInputOnDown2p && UGUIOperationInvalid2p != true ||
                Mapper.jInputOnDown3p && UGUIOperationInvalid3p != true ||
                Mapper.jInputOnDown4p && UGUIOperationInvalid4p != true)
            {
                UGUIDownMove();
            }
            if (Mapper.jInputOnRight && UGUIOperationInvalid != true ||
                Mapper.jInputOnRight2p && UGUIOperationInvalid2p != true ||
                Mapper.jInputOnRight3p && UGUIOperationInvalid3p != true ||
                Mapper.jInputOnRight4p && UGUIOperationInvalid4p != true)
            {
                UGUIRightMove();
            }
            if (Mapper.jInputOnLeft && UGUIOperationInvalid != true ||
                Mapper.jInputOnLeft2p && UGUIOperationInvalid2p != true ||
                Mapper.jInputOnLeft3p && UGUIOperationInvalid3p != true ||
                Mapper.jInputOnLeft4p && UGUIOperationInvalid4p != true)
            {
                UGUILeftMove();
            }
            if (Mapper.UGUIOnSubmit && UGUIOperationInvalid != true ||
                Mapper.UGUIOnSubmit2p && UGUIOperationInvalid2p != true ||
                Mapper.UGUIOnSubmit3p && UGUIOperationInvalid3p != true ||
                Mapper.UGUIOnSubmit4p && UGUIOperationInvalid4p != true)
            {
                UGUISubmit();
            }
            if (Mapper.UGUIOnCancel && UGUIOperationInvalid != true ||
                Mapper.UGUIOnCancel2p && UGUIOperationInvalid2p != true ||
                Mapper.UGUIOnCancel3p && UGUIOperationInvalid3p != true ||
                Mapper.UGUIOnCancel4p && UGUIOperationInvalid4p != true)
            {
                UGUICancel();
            }
        }
    }
        protected virtual AxisEventData GetAxisEventData(float x, float y, float moveDeadZone)
        {
            if (m_AxisEventData == null)
                m_AxisEventData = new AxisEventData(eventSystem);

            m_AxisEventData.Reset();
            m_AxisEventData.moveVector = new Vector2(x, y);
            m_AxisEventData.moveDir = DetermineMoveDirection(x, y, moveDeadZone);
            return m_AxisEventData;
        }