Exemplo n.º 1
0
        /// <summary>
        /// Process all mouse events. This is the same as the StandaloneInputModule version except that
        /// it takes MouseState as a parameter, allowing it to be used for both Gaze and Mouse
        /// pointerss.
        /// </summary>
        private void ProcessMouseEvent(MouseState mouseData)
        {
            var pressed  = mouseData.AnyPressesThisFrame();
            var released = mouseData.AnyReleasesThisFrame();

            var leftButtonData = mouseData.GetButtonState(PointerEventData.InputButton.Left).eventData;

            if (!UseMouse(pressed, released, leftButtonData.buttonData))
            {
                return;
            }

            // Process the first mouse button fully
            ProcessMousePress(leftButtonData);
            ProcessMove(leftButtonData.buttonData);
            ProcessDrag(leftButtonData.buttonData);

            // Now process right / middle clicks
            ProcessMousePress(mouseData.GetButtonState(PointerEventData.InputButton.Right).eventData);
            ProcessDrag(mouseData.GetButtonState(PointerEventData.InputButton.Right).eventData.buttonData);
            ProcessMousePress(mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData);
            ProcessDrag(mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData.buttonData);

            if (!Mathf.Approximately(leftButtonData.buttonData.scrollDelta.sqrMagnitude, 0.0f))
            {
                var scrollHandler = ExecuteEvents.GetEventHandler <IScrollHandler>(leftButtonData.buttonData.pointerCurrentRaycast.gameObject);
                ExecuteEvents.ExecuteHierarchy(scrollHandler, leftButtonData.buttonData, ExecuteEvents.scrollHandler);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Process all mouse events. This is the same as the StandaloneInputModule version except that
        /// it takes MouseState as a parameter, allowing it to be used for both Gaze and Mouse 
        /// pointerss.
        /// </summary>
        private void ProcessMouseEvent(MouseState mouseData)
        {
            var pressed = mouseData.AnyPressesThisFrame();
            var released = mouseData.AnyReleasesThisFrame();

            var leftButtonData = mouseData.GetButtonState(PointerEventData.InputButton.Left).eventData;

            if (!UseMouse(pressed, released, leftButtonData.buttonData))
                return;

            // Process the first mouse button fully
            ProcessMousePress(leftButtonData);
            ProcessMove(leftButtonData.buttonData);
            ProcessDrag(leftButtonData.buttonData);

            // Now process right / middle clicks
            ProcessMousePress(mouseData.GetButtonState(PointerEventData.InputButton.Right).eventData);
            ProcessDrag(mouseData.GetButtonState(PointerEventData.InputButton.Right).eventData.buttonData);
            ProcessMousePress(mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData);
            ProcessDrag(mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData.buttonData);

            if (!Mathf.Approximately(leftButtonData.buttonData.scrollDelta.sqrMagnitude, 0.0f))
            {
                var scrollHandler = ExecuteEvents.GetEventHandler<IScrollHandler>(leftButtonData.buttonData.pointerCurrentRaycast.gameObject);
                ExecuteEvents.ExecuteHierarchy(scrollHandler, leftButtonData.buttonData, ExecuteEvents.scrollHandler);
            }
        }
Exemplo n.º 3
0
        private void ProcessMouseEventForPC()
        {
            if (m_Disable == true)
            {
                return;
            }

            //----------------------------------

            MouseState mouseData = GetMousePointerEventData();

            bool pressed  = mouseData.AnyPressesThisFrame();
            bool released = mouseData.AnyReleasesThisFrame();

            MouseButtonEventData leftButtonData = mouseData.GetButtonState(PointerEventData.InputButton.Left).eventData;

            if (leftButtonData.PressedThisFrame() == true)
            {
                m_LastPress = leftButtonData.buttonData.pointerCurrentRaycast.gameObject;
//				Debug.LogWarning( "LastPress設定:" + m_LastPress ) ;
            }

            //レイキャスト消失により Relese 状態になった場合の対応
            bool isPressed = Input.GetMouseButton(0);

            if (isPressed != m_IsPressed)
            {
//				if( isPressed == false )
//				{
//					Debug.LogWarning( "直判定で離された:" + leftButtonData.buttonState ) ;
//				}

                if (released == false && isPressed == false)
                {
                    released = true;

                    if (leftButtonData.buttonState == PointerEventData.FramePressState.NotChanged)
                    {
                        leftButtonData.buttonState = PointerEventData.FramePressState.Released;

//						Debug.LogWarning( "LastPress:" + m_LastPress ) ;

                        leftButtonData.buttonData.pointerPress = m_LastPress;
                        m_LastPress = null;
                    }
                }

                m_IsPressed = isPressed;
            }

            // マウスオーバーに関してはマウスが動いていなくても取りたい
            ProcessHoverForPC(leftButtonData.buttonData);

            if (UseMouseForPC(pressed, released, leftButtonData.buttonData) == false)
            {
                // 何のイベントも無い
                return;
            }

            // Process the first mouse button fully
            ProcessMousePress(leftButtonData);                  // デフォルトでは途中でレイキャストが変わった場合のリリースがうまくいかないので改造版を使用する
//			ProcessMove( leftButtonData.buttonData ) ;
            ProcessDrag(leftButtonData.buttonData);

            // Now process right / middle clicks
//			ProcessMousePress( mouseData.GetButtonState( PointerEventData.InputButton.Right ).eventData ) ;
//			ProcessDrag( mouseData.GetButtonState( PointerEventData.InputButton.Right ).eventData.buttonData ) ;
//			ProcessMousePress( mouseData.GetButtonState( PointerEventData.InputButton.Middle ).eventData ) ;
//			ProcessDrag( mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData.buttonData ) ;

            if (Mathf.Approximately(leftButtonData.buttonData.scrollDelta.sqrMagnitude, 0.0f) == false)
            {
                GameObject scrollHandler = ExecuteEvents.GetEventHandler <IScrollHandler>(leftButtonData.buttonData.pointerCurrentRaycast.gameObject);
                ExecuteEvents.ExecuteHierarchy(scrollHandler, leftButtonData.buttonData, ExecuteEvents.scrollHandler);
            }
        }