protected override void Awake() { base.Awake(); triggerGestureButton = new GestureButtonStates(false); gripGestureButton = new GestureButtonStates(false); touchPadGestureButton = new GestureButtonStates(false); buttonOneGestureButton = new GestureButtonStates(false); buttonTwoGestureButton = new GestureButtonStates(false); startMenuGestureButton = new GestureButtonStates(false); }
protected virtual void CheckGestureButtonReleased(ref GestureButtonStates givenGestureButton, Gesture givenGesture, Action buttonReleaseAction) { // Pressed end givenGestureButton.wasReleasedThisFrame = !givenGesture.IsGestureOccuring(controllerHandId); if (givenGestureButton.wasReleasedThisFrame && !givenGestureButton.wasReleasedLastFrame && givenGestureButton.isGestureButtonPressed) { givenGestureButton.isGestureButtonPressed = false; buttonReleaseAction(); } }
protected virtual void CheckGestureButtonPressed(ref GestureButtonStates givenGestureButton, Gesture givenGesture, Action buttonPressAction) { // Pressed start givenGestureButton.wasPressedThisFrame = givenGesture.IsGestureOccuring(controllerHandId); if (givenGestureButton.wasPressedThisFrame && !givenGestureButton.wasPressedLastFrame && !givenGestureButton.isGestureButtonPressed) { givenGestureButton.isGestureButtonPressed = true; buttonPressAction(); } }
/// <summary> /// General call for checking if a gesture button has reached it's press/release state /// </summary> /// <param name="givenGestureButton">The parameter that holds the state of the gesture button</param> /// <param name="givenGesture">The Gesture that contains the gesture info of what needs to be checked</param> /// <param name="buttonPressAction">What actions to take when the gesture-button reaches the press state</param> /// <param name="buttonReleaseAction">What actions to take when the gesture-button reaches the release state</param> protected virtual void CheckGestureButton(ref GestureButtonStates givenGestureButton, Gesture givenGesture, Action buttonPressAction, Action buttonReleaseAction) { if (givenGesture == null) { return; } CheckGestureButtonPressed(ref givenGestureButton, givenGesture, buttonPressAction); CheckGestureButtonReleased(ref givenGestureButton, givenGesture, buttonReleaseAction); //Save frame information givenGestureButton.wasPressedLastFrame = givenGestureButton.wasPressedThisFrame; givenGestureButton.wasReleasedLastFrame = givenGestureButton.wasReleasedThisFrame; }