protected virtual void DoInteractableObjectIsGrabbed(object sender, InteractableObjectEventArgs e) { controllerEvents = e.interactingObject.GetComponent <VRTK_ControllerEvents>(); if (controllerEvents != null) { BindControllerEvents(); } isGrabbed = true; statutDesc = true; for (int i = 0; i < presentationPanel.transform.childCount; i++) { if (presentationPanel.transform.GetChild(i).gameObject.activeSelf == true) { presentationPanel.transform.GetChild(i).gameObject.SetActive(false); } } for (int i = 1; i < allPanelMenuItemController.Count; i++) { if (allPanelMenuItemController[i].gameObject.activeSelf == true) { allPanelMenuItemController[i].gameObject.SetActive(false); } } currentPanelMenuItemController = allPanelMenuItemController[0]; descPanel.SetActive(true); currentPanelMenuItemController.gameObject.SetActive(true); }
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; * } */ } }
void RpcOnSwipRight() { if (currentPanelMenuItemController != null) { if (currentPanelId + 1 < allPanelMenuItemController.Count) { currentPanelId += 1; swapEffectSource.PlayOneShot(swapEffectClip); currentPanelMenuItemController.gameObject.SetActive(false); currentPanelMenuItemController = allPanelMenuItemController[currentPanelId]; currentPanelMenuItemController.gameObject.SetActive(true); } } }
//Action si swip Droite protected virtual void OnSwipeRight() { if (currentPanelMenuItemController != null) { if (currentPanelId + 1 < allPanelMenuItemController.Count) { //Passage à la page suivante si le pannel actuel n'est pas la dernière page currentPanelId += 1; swapEffectSource.PlayOneShot(swapEffectClip); currentPanelMenuItemController.gameObject.SetActive(false); currentPanelMenuItemController = allPanelMenuItemController[currentPanelId]; currentPanelMenuItemController.gameObject.SetActive(true); } } }
//Action si Swipt Gauche protected virtual void OnSwipeLeft() { if (currentPanelMenuItemController != null) { //Passage à la page précédente si le pannel actuel n'est pas la première page if (currentPanelId - 1 >= 0) { currentPanelId -= 1; swapEffectSource.PlayOneShot(swapEffectClip); currentPanelMenuItemController.gameObject.SetActive(false); currentPanelMenuItemController = allPanelMenuItemController[currentPanelId]; currentPanelMenuItemController.gameObject.SetActive(true); } } }
protected virtual void OnSwipeRight() { if (currentPanelMenuItemController != null) { //currentPanelMenuItemController.SwipeRight(interactableObject); if (currentPanelId + 1 < allPanelMenuItemController.Count) { currentPanelId += 1; swapEffectSource.PlayOneShot(swapEffectClip); currentPanelMenuItemController.gameObject.SetActive(false); currentPanelMenuItemController = allPanelMenuItemController[currentPanelId]; currentPanelMenuItemController.gameObject.SetActive(true); } } }
void RpcDesactiveObjDescPanel(GameObject descObjPanel) { currentPanelId = 0; objectsIsGrabbed -= 1; if (objectsIsGrabbed == 1) { if (descObjPanel == currentDescObjPanel) { currentDescObjPanel = previousDescObjPanel; } allPanelMenuItemController = new List <VRTK_PanelMenuItemController>(); for (int i = 0; i < currentDescObjPanel.transform.GetChild(0).gameObject.transform.childCount; i++) { allPanelMenuItemController.Add(currentDescObjPanel.transform.GetChild(0).gameObject.transform.GetChild(i).gameObject.GetComponent <VRTK_PanelMenuItemController>()); } for (int i = 0; i < presentationPanel.transform.childCount; i++) { if (presentationPanel.transform.GetChild(i).gameObject.activeSelf == true) { presentationPanel.transform.GetChild(i).gameObject.SetActive(false); } } for (int i = 1; i < allPanelMenuItemController.Count; i++) { if (allPanelMenuItemController[i].gameObject.activeSelf == true) { allPanelMenuItemController[i].gameObject.SetActive(false); } } currentPanelMenuItemController = allPanelMenuItemController[0]; currentDescObjPanel.SetActive(true); currentPanelMenuItemController.gameObject.SetActive(true); } }
/// <summary> /// Observable PanelMenuItemTriggerPressed event /// </summary> /// <param name="events"></param> /// <returns></returns> public static IObservable <PanelMenuItemControllerEventArgs> PanelMenuItemTriggerPressedAsObservable(this VRTK_PanelMenuItemController events) { return(Observable.FromEvent <PanelMenuItemControllerEventHandler, PanelMenuItemControllerEventArgs>( h => (s, e) => h(e), h => events.PanelMenuItemTriggerPressed += h, h => events.PanelMenuItemTriggerPressed -= h)); }
/// <summary> /// Observable PanelMenuItemSwipeBottom event /// </summary> /// <param name="events"></param> /// <returns></returns> public static IObservable <PanelMenuItemControllerEventArgs> PanelMenuItemSwipeBottomAsObservable(this VRTK_PanelMenuItemController events) { return(Observable.FromEvent <PanelMenuItemControllerEventHandler, PanelMenuItemControllerEventArgs>( h => (s, e) => h(e), h => events.PanelMenuItemSwipeBottom += h, h => events.PanelMenuItemSwipeBottom -= h)); }
protected virtual void DoTouchpadPress(object sender, ControllerInteractionEventArgs e) { if (isGrabbed) { //Use it if you want a speculare touchpad press position// //var pressPosition = CalculateTouchpadPressPosition(); currentPanelId = 0; if (descPanel.activeSelf == true) { statutDesc = false; } else { statutDesc = true; } if (statutDesc == true) { for (int i = 1; i < allPanelMenuItemController.Count; i++) { if (allPanelMenuItemController[i].gameObject.activeSelf == true) { allPanelMenuItemController[i].gameObject.SetActive(false); } } for (int i = 0; i < presentationPanel.transform.childCount; i++) { if (presentationPanel.transform.GetChild(i).gameObject.activeSelf == true) { presentationPanel.transform.GetChild(i).gameObject.SetActive(false); } } descPanel.SetActive(true); currentPanelMenuItemController = allPanelMenuItemController[0]; currentPanelMenuItemController.gameObject.SetActive(true); } else { currentPanelMenuItemController.gameObject.SetActive(false); for (int i = 0; i < allPanelMenuItemController.Count; i++) { if (allPanelMenuItemController[i].gameObject.activeSelf == true) { allPanelMenuItemController[i].gameObject.SetActive(false); } } for (int i = 1; i < presentationPanel.transform.childCount; i++) { if (presentationPanel.transform.GetChild(i).gameObject.activeSelf == true) { presentationPanel.transform.GetChild(i).gameObject.SetActive(false); } } presentationPanel.transform.GetChild(0).gameObject.SetActive(true); } /* switch (pressPosition) * { * case TouchpadPressPosition.Top: * UpBtnPushed(); * break; * * case TouchpadPressPosition.Bottom: * DownBtnPushed(); * break; * * case TouchpadPressPosition.Left: * * break; * * case TouchpadPressPosition.Right: * * break; * }*/ } }