protected virtual void HandlePanelMenuItemControllerVisibility(VRTK_PanelMenuItemController targetPanelItemController) { if (isShown) { if (currentPanelMenuItemController == targetPanelItemController) { targetPanelItemController.Hide(interactableObject); currentPanelMenuItemController = null; HideMenu(true); } else { currentPanelMenuItemController.Hide(interactableObject); currentPanelMenuItemController = targetPanelItemController; } } else { currentPanelMenuItemController = targetPanelItemController; } if (currentPanelMenuItemController != null) { currentPanelMenuItemController.Show(interactableObject); ShowMenu(); } }
protected virtual void DoTouchpadPress(object sender, ControllerInteractionEventArgs e) { if (isGrabbed) { //HandlePanelMenuItemControllerVisibility(allPanelMenuItemController[currentPanelId]); if (currentPanelMenuItemController == null) { currentPanelMenuItemController = allPanelMenuItemController[0]; currentPanelMenuItemController.Show(interactableObject); ShowMenu(); } else { allPanelMenuItemController[currentPanelId].Hide(interactableObject); currentPanelMenuItemController = null; HideMenu(true); } currentPanelId = 0; //Use it if you want a speculare touchpad press position// /*var pressPosition = CalculateTouchpadPressPosition(); * * * switch (pressPosition) * { * case TouchpadPressPosition.Top: * if (topPanelMenuItemController != null) * { * HandlePanelMenuItemControllerVisibility(topPanelMenuItemController); * } * break; * * case TouchpadPressPosition.Bottom: * if (bottomPanelMenuItemController != null) * { * HandlePanelMenuItemControllerVisibility(bottomPanelMenuItemController); * } * break; * * case TouchpadPressPosition.Left: * if (leftPanelMenuItemController != null) * { * HandlePanelMenuItemControllerVisibility(leftPanelMenuItemController); * } * break; * * case TouchpadPressPosition.Right: * if (rightPanelMenuItemController != null) * { * HandlePanelMenuItemControllerVisibility(rightPanelMenuItemController); * } * break; * } */ } }