コード例 #1
0
        protected virtual void ReadTouchpad()
        {
            var touchPoint = new Vector2(VRInput.GetAxis(nodeState, InputAxis.JoypadX), VRInput.GetAxis(nodeState, InputAxis.JoypadY));

            var touchButton = VRInput.GetTouch(nodeState, InputAxis.Joypad) > .5f;

            if (touchButton)
            {
                var delta = touchPoint - lastTouchPoint;
                if (!touchIsScrolling)
                {
                    if (delta.magnitude * trackpadScrollSpeed > scrollThreshold)
                    {
                        touchIsScrolling = true;
                        lastTouchPoint   = touchPoint;
                    }
                    else
                    {
                        //don't start updating the touch point yet
                    }
                }
                else
                {
                    ScrollDelta    = new Vector2(-delta.x, delta.y) * trackpadScrollSpeed;
                    lastTouchPoint = touchPoint;
                }
            }
            else
            {
                ScrollDelta      = new Vector2();
                lastTouchPoint   = touchPoint;
                touchIsScrolling = false;
            }
        }
コード例 #2
0
        private void ButtonStateLabel(VRButton button)
        {
            var state = "Up";

            if (VRInput.GetButton(button))
            {
                state = "Down";
            }
            else if (VRInput.GetTouch(button))
            {
                state = "Touching";
            }
            else if (VRInput.GetHovering(button) > Mathf.Epsilon)
            {
                state = "Hovering";
            }

            UnityGUI.Label(button.ToString() + ": " + state);
        }