// Panel Menu Item|Prefabs|0140 namespace VRTK { using UnityEngine; /// /// Event Payload /// /// The GameObject for the interactable object the PanelMenu is attached to. public struct PanelMenuItemControllerEventArgs { public GameObject interactableObject; } /// /// Event Payload /// /// this object /// public delegate void PanelMenuItemControllerEventHandler(object sender, PanelMenuItemControllerEventArgs e); /// /// Intercepts the controller events sent from a `VRTK_PanelMenuController` and passes them onto additional custom event subscriber scripts, which then carry out the required custom UI actions. /// /// /// > This script is not directly part of a prefab but is a helper associated to the `PanelMenu` prefab. /// /// * Place the `VRTK/Prefabs/PanelMenu/VRTK_PanelMenuItemController` script on the child GameObject of any Panel Item Container which is contained within the `PanelMenuController` prefab within the scene. /// * Pick up the VRTK_InteractableObject show/hide the panel menu by pressing the touchpad top/bottom/left/right you can open/close the child UI panel that has been assigned via the Unity Editor panel. /// /// /// `040_Controls_Panel_Menu` contains three basic interactive object examples of the PanelMenu in use. /// public class VRTK_PanelMenuItemController : MonoBehaviour { /// /// Emitted when the panel menu item is showing. /// public event PanelMenuItemControllerEventHandler PanelMenuItemShowing; /// /// Emitted when the panel menu item is hiding. /// public event PanelMenuItemControllerEventHandler PanelMenuItemHiding; /// /// Emitted when the panel menu item is open and the user swipes left on the controller touchpad. /// public event PanelMenuItemControllerEventHandler PanelMenuItemSwipeLeft; /// /// Emitted when the panel menu item is open and the user swipes right on the controller touchpad. /// public event PanelMenuItemControllerEventHandler PanelMenuItemSwipeRight; /// /// Emitted when the panel menu item is open and the user swipes top on the controller touchpad. /// public event PanelMenuItemControllerEventHandler PanelMenuItemSwipeTop; /// /// Emitted when the panel menu item is open and the user swipes bottom on the controller touchpad. /// public event PanelMenuItemControllerEventHandler PanelMenuItemSwipeBottom; /// /// Emitted when the panel menu item is open and the user presses the trigger of the controller holding the interactable object. /// public event PanelMenuItemControllerEventHandler PanelMenuItemTriggerPressed; public virtual void OnPanelMenuItemShowing(PanelMenuItemControllerEventArgs e) { if (PanelMenuItemShowing != null) { PanelMenuItemShowing(this, e); } } public virtual void OnPanelMenuItemHiding(PanelMenuItemControllerEventArgs e) { if (PanelMenuItemHiding != null) { PanelMenuItemHiding(this, e); } } public virtual void OnPanelMenuItemSwipeLeft(PanelMenuItemControllerEventArgs e) { if (PanelMenuItemSwipeLeft != null) { PanelMenuItemSwipeLeft(this, e); } } public virtual void OnPanelMenuItemSwipeRight(PanelMenuItemControllerEventArgs e) { if (PanelMenuItemSwipeRight != null) { PanelMenuItemSwipeRight(this, e); } } public virtual void OnPanelMenuItemSwipeTop(PanelMenuItemControllerEventArgs e) { if (PanelMenuItemSwipeTop != null) { PanelMenuItemSwipeTop(this, e); } } public virtual void OnPanelMenuItemSwipeBottom(PanelMenuItemControllerEventArgs e) { if (PanelMenuItemSwipeBottom != null) { PanelMenuItemSwipeBottom(this, e); } } /// /// The SetPanelMenuItemEvent is used to build up the event payload. /// /// The object the menu is attached to. /// The payload for the event. public virtual PanelMenuItemControllerEventArgs SetPanelMenuItemEvent(GameObject interactableObject) { PanelMenuItemControllerEventArgs e; e.interactableObject = interactableObject; return e; } /// /// The Show method is used to show the menu. /// /// The object the menu is attached to. public virtual void Show(GameObject interactableObject) { gameObject.SetActive(true); OnPanelMenuItemShowing(SetPanelMenuItemEvent(interactableObject)); } /// /// The Hide method is used to show the menu. /// /// The object the menu is attached to. public virtual void Hide(GameObject interactableObject) { gameObject.SetActive(false); OnPanelMenuItemHiding(SetPanelMenuItemEvent(interactableObject)); } /// /// The SwipeLeft method is used when the control is swiped left. /// /// The object the menu is attached to. public virtual void SwipeLeft(GameObject interactableObject) { OnPanelMenuItemSwipeLeft(SetPanelMenuItemEvent(interactableObject)); } /// /// The SwipeRight method is used when the control is swiped right. /// /// The object the menu is attached to. public virtual void SwipeRight(GameObject interactableObject) { OnPanelMenuItemSwipeRight(SetPanelMenuItemEvent(interactableObject)); } /// /// The SwipeTop method is used when the control is swiped up. /// /// The object the menu is attached to. public virtual void SwipeTop(GameObject interactableObject) { OnPanelMenuItemSwipeTop(SetPanelMenuItemEvent(interactableObject)); } /// /// The SwipeBottom method is used when the control is swiped down. /// /// The object the menu is attached to. public virtual void SwipeBottom(GameObject interactableObject) { OnPanelMenuItemSwipeBottom(SetPanelMenuItemEvent(interactableObject)); } /// /// The TriggerPressed method is used when the control action button is pressed. /// /// The object the menu is attached to. public virtual void TriggerPressed(GameObject interactableObject) { OnPanelMenuItemTriggerPressed(SetPanelMenuItemEvent(interactableObject)); } protected virtual void OnPanelMenuItemTriggerPressed(PanelMenuItemControllerEventArgs e) { if (PanelMenuItemTriggerPressed != null) { PanelMenuItemTriggerPressed(this, e); } } } }