WaveVR EventSystem

Old version (2.1.8 and before): WaveVR EventSystem

Introduction

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

In WaveVR, we provide several scripts and samples showing how to use Event System in a VR environment.

Documents

Developer can read the documents below to learn about the WaveVR Event System:

Gaze Input

If a VR environment does not have a controller, how does the user control items?

The answer is Gaze.

Gaze is sending events through the Event System to the center of the screen where a user is looking.

When Game Objects receive events, corresponding actions are taken.

Controller Input

In this document, WaveVR shows how to use the Event System on multiple controllers.

Usage

WaveVR provides a very easy way to use EventSystem for Gaze & Controller concurrently and steps are introduced below:

  1. Add Input Module:

    Drag prefab Assets/WaveVR/Prefabs/InputModuleManager to scene. About this prefab, refer to Input Module Manager

  2. Add Controller:

    Drag prefab Assets/WaveVR/Prefabs/ControllerLoader to scene. About this prefab, refer to WaveVR_ControllerLoader

  3. Customize Event Handler:

    Event Handler is used to handle events . WaveVR provides a sample script WaveVR_EventHandler in Assets/WaveVR/Extra/EventSystem. Developer can simply copy the script and overwrite APIs in 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)
  1. Setup event UGUI:

    Add WaveVR_AddEventSystemGUI to Canvas which can receive events.

Practice

Let’s have a practice from beginning.

Before start up, we need to prepare a scene, so creating a new scene as below:

_images/purescene.png

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

_images/purescene_cube.png

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

_images/purescene_cubebtn.png

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

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

_images/purescene_canvas1.png

Initial scene is ready now, let’s use EventSystem step-by-step:

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

Done. Now developer can play scene in editor mode to see the effect.

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