WaveVR EventSystem

Older versions (3.0.x and before) can be found here: WaveVR EventSystem

Introduction

Unity provides the Event System to send events to objects in the application based on input, be it keyboard, mouse, touch, or custom input.

In this document, we will introduce how to use the VIVE Wave™ Event System.

For more information of the VIVE Wave™ Event System components, you can refer to the documents below:

Practice

Considering you already have a scene with the components below:

  • A 3D cube
  • A UGUI button
  • A UGUI dropdown menu

The scene looks like the photo below:

_images/WaveVR_EventSystem01.png

The project hierarchy looks like the photo below:

_images/WaveVR_EventSystem02.png

For using the VIVE Wave™ Event System, follow the steps below:

  1. Drag the prefab Assets/WaveVR/Prefabs/WaveVR into the scene like the photo below. This prefab is the basic component of VIVE Wave™ SDK.

    _images/WaveVR_EventSystem03.png
  2. Drag the prefab Assets/WaveVR/Prefabs/InputModuleManager into the scene like the photo below. This prefab will manage the input module in runtime.

    _images/WaveVR_EventSystem04.png
  3. Drag the prefab Assets/WaveVR/Prefabs/ControllerLoader into the scene like the photo below. This prefab will load the controller model in runtime.

    _images/WaveVR_EventSystem05.png
  4. Drag the prefab Assets/WaveVR/Prefabs/WaveVRButtons into the scene like the photo below. This prefab will handle the button events in runtime.

    _images/WaveVR_EventSystem06.png
  5. Add the component WaveVR_EventHandler to the cube like the photo below. This script is located in Assets/WaveVR/Extra/EventSystem/

    _images/WaveVR_EventSystem07.png

After all steps are done, you can play the scene in editor mode and follow the operations below to interact with the scene:

  • Hold the Right Alt key and move the mouse to move the controller model.
  • Hold the Left Alt key and move the mouse to change the head rotation.
  • Right-click on the mouse to send a click event to the cube, button and dropdown menu.
  • Hold the right mouse button to drag the cube.

Customized Event Handler

To handle the events , you will have to write your own Event Handler. VIVE Wave™ SDK provides a sample script WaveVR_EventHandler in Assets/WaveVR/Extra/EventSystem. You can simply copy the script and overwrite the APIs inside the region #region override event handling function.

#region override event handling function
public void OnPointerEnter (PointerEventData eventData)
public void OnPointerExit (PointerEventData eventData)
public void OnPointerDown (PointerEventData eventData)
public void OnBeginDrag(PointerEventData eventData)
public void OnDrag(PointerEventData eventData)
public void OnEndDrag(PointerEventData eventData)
public void OnDrop(PointerEventData eventData)
public void OnPointerHover (PointerEventData eventData)