public void UpdateState(OVRHand hand, bool _displayLog) { float pinchStrength = hand.GetFingerPinchStrength(OVRHand.HandFinger.Index); bool isPinching = Mathf.Abs(PINCH_STRENGTH_THRESHOLD - pinchStrength) < Mathf.Epsilon; var oldPinchState = _currPinchState; // if (_displayLog) UIEventController.Instance.DelayUIEvent(ScreenDebugLogView.EVENT_SCREEN_DEBUGLOG_NEW_TEXT, 3, true, "old[" + oldPinchState.ToString() + "]::strength[" + pinchStrength + "]::isPinching[" + isPinching + "]::IsDataValid[" + hand.IsDataValid + "]"); switch (oldPinchState) { case MyPinchState.PinchUp: // can only be in pinch up for a single frame, so consider // next frame carefully if (isPinching) { _currPinchState = MyPinchState.PinchDown; } else { _currPinchState = MyPinchState.None; } break; case MyPinchState.PinchStay: if (!isPinching) { _currPinchState = MyPinchState.PinchUp; } break; // pinch down lasts for a max of 1 frame. either go to pinch stay or up case MyPinchState.PinchDown: _currPinchState = isPinching ? MyPinchState.PinchStay : MyPinchState.PinchUp; break; default: if (isPinching) { _currPinchState = MyPinchState.PinchDown; // this is the interactable that must be focused through out the pinch up and down // gesture. } break; } }
public PinchStateCustom() { _currPinchState = MyPinchState.None; }