Exemple #1
0
        void ProcessHandPinch(OVRInput.Controller activeController, Transform lastHit,
                              ref Transform triggerDown, ref Transform padDown, ref Transform tertiaryDown)
        {
            // Handle selection callbacks. An object is selected if the button selecting it was
            // pressed AND released while hovering over the object.
            if ((activeController & OVRInput.Controller.Hands) == OVRInput.Controller.None)
            {
                return;
            }

            if (!OVRPlugin.GetHandTrackingEnabled() || !HandsManager.Instance || !HandsManager.Instance.IsInitialized())
            {
                return;
            }

            if (OVRInputHelpers.IsFingerStartPinching(activeController, tertiaryPinchFinger))
            {
                tertiaryDown = lastHit;
            }
            else if (OVRInputHelpers.IsFingerStopPinching(activeController, tertiaryPinchFinger))
            {
                if (tertiaryDown != null && tertiaryDown == lastHit)
                {
                    if (onTertiarySelect != null)
                    {
                        onTertiarySelect.Invoke(tertiaryDown);
                    }
                }
            }
            else if (!OVRInputHelpers.IsFingerPinching(activeController, tertiaryPinchFinger))
            {
                tertiaryDown = null;
            }

            if (OVRInputHelpers.IsFingerStartPinching(activeController, secondaryPinchFinger))
            {
                padDown = lastHit;
            }
            else if (OVRInputHelpers.IsFingerStopPinching(activeController, secondaryPinchFinger))
            {
                if (padDown != null && padDown == lastHit)
                {
                    if (onSecondarySelect != null)
                    {
                        onSecondarySelect.Invoke(padDown);
                    }
                }
            }
            else if (!OVRInputHelpers.IsFingerPinching(activeController, secondaryPinchFinger))
            {
                padDown = null;
            }

            if (OVRInputHelpers.IsFingerStartPinching(activeController, primaryPinchFinger))
            {
                triggerDown = lastHit;
            }
            else if (OVRInputHelpers.IsFingerStopPinching(activeController, primaryPinchFinger))
            {
                if (triggerDown != null && triggerDown == lastHit)
                {
                    if (onPrimarySelect != null)
                    {
                        onPrimarySelect.Invoke(triggerDown);
                    }
                }
            }
            else if (!OVRInputHelpers.IsFingerPinching(activeController, primaryPinchFinger))
            {
                triggerDown = null;
            }
        }