WaveVR EventSystem

Older versions (2.1.8 and before) can be found here: WaveVR EventSystem

New version can be found here: WaveVR EventSystem

Introduction

Unity provides the Event System to receive input from standard I/O and communicate among different Game Objects.

In WaveVR, we provide several scripts and samples for using the Event System in a VR environment.

Documents

The documents below are related to the input module of the Event System.

Gaze Input

If there is no controller in a VR environment, how do you interact with items?

The answer is the Gaze feature.

The Gaze feature is sending the events through the Event System to the center of your view.

When a GameObject receives the events, it can take the corresponding actions.

Controller Input

In this document, we introduce how to use the Event System with multiple controllers.

Usage

WaveVR provides a simple way to use the Gaze feature and the Controller feature concurrently in the Event System.

Assume that you already have a scene, please follow steps below:

  1. Add an input module:
    Drag the prefab Assets/WaveVR/Prefabs/InputModuleManager to the scene. For more information about this prefab, please refer to Input Module Manager
  2. Add a controller:
    Drag the prefab Assets/WaveVR/Prefabs/ControllerLoader to scene. For more information about this prefab, please refer to WaveVR_ControllerLoader
  3. Write a customized Event Handler:
    The Event Handler is used to handle events . WaveVR 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)

Practice

You can start from the beginning as practice.

Before starting up, you will need to prepare a scene, so create a new scene as below:

_images/purescene.png

Considering a scene always has 3D physical object(s), add a simple cube:

_images/purescene_cube.png

Considering a scene also has GUI(s), add a simple button:

_images/purescene_cubebtn.png

When adding a Button, the Canvas and the EventSystem will also be added automatically.

Note: must change the Render Mode of Canvas to World Space:

_images/purescene_canvas1.png

The initial scene is ready now, below is how you can use the Event System step-by-step:

  1. Remove the Main Camera, drag the WaveVR prefab from Assets/WaveVR/Prefab/ - for enabling WaveVR rendering.
_images/purescene_wavevr.png
  1. Drag the ControllerLoader prefab from Assets/WaveVR/Prefabs/ and choose options - for using a controller.
_images/purescene_controller.png
  1. Drag the InputModuleManager prefab from Assets/WaveVR/Prefabs/.
_images/purescene_inputmodulemanager.png
  1. Add the component WaveVR_AddEventSystemGUI to GUI (Canvas of Button).
_images/purescene_canvas.png
  1. Add the component WaveVR_EventHandler to Cube
_images/purescene_eventhandler.png

You are done. You can now play the scene in editor mode to see the effect.

Hint: use Right-Alt + mouse to controll the controller in scene.