WaveVR EventSystem

Contents

Introduction

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

WaveVR provides a variety of scripts and samples showing how to use the Event System in a VR environment.

Documents

Please read the documents below to learn about the WaveVR Event System:

Gaze Input

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

The answer is Gaze.

Gaze is a feature that sends events through the Event System to the center of the view where a user is looking.

When an object receives events, the corresponding actions are taken.

Controller Input

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

Advanced Usage

Common questions for GazeInputModule and WaveVR Controller Input Module include:

E.g.

  • Is there an easier way to use EventSystem?
  • Can I use the Gaze & Controller concurrently?
  • Can I enable/disable Gaze or Controller Input Module in runtime?
  • What does the scene MixedInputModule_Test in Assets/Samples/ControllerInputModule_Test demonstrate for?

WaveVR provides a very simple way to use EventSystem for the Gaze and the Controller input module concurrently introduced below:

Sample

  1. Open the sample scene MixedInputModule_Test under Assets/Samples/ControllerInputModule_Test/Scenes/
_images/MixedInputModule_Test.png
  1. The InputModuleManager is a prefab from Assets/WaveVR/Prefabs. Please refer to
  1. The ControllerLoader_R and ControllerLoader_L are already introduced in WaveVR Controller Input Module .

    They are prefabs from Assets/WaveVR/Prefabs used to load the controller model. You need to select Which Hand and Tracking Method.

    3DOF means tracking the rotation only. 6DOF means tracking the rotation and the position.

_images/ControllerLoader_L.png _images/ControllerLoader_R.png
  1. In WaveVR Controller Input Module , WaveVR_AddEventSystemGUI.cs is introduced.

    It is used to mark the canvas which can receive events from EventSystem.

_images/rightmenucanvas_addeventsystemgui.png
  1. Last, set your own Event Handler to handle events .

    WaveVR provides a sample script WaveVR_EventHandler in Assets/WaveVR/Extra/EventSystem.

    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)

In this sample, we use the WaveVR_EventHandler script in Cube.

_images/cube.png

Now, all components needed in EventSystem are ready:

  1. InputModule (controlled by WaveVR_InputModuleManager).
  2. Head component (prefab InputModuleManager).
  3. Controller component (loaded by ControllerLoader).
  4. PhysicsRaycaster (contained in head and controller component).
  5. GraphicRaycaster (specified by WaveVR_AddEventSystemGUI)
  6. Event handler (override WaveVR_EventHandler)

Summary

So, in a scene without EventSystem, you now know how to enable EventSystem. 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: You must change the Render Mode of the Canvas to World Space:

_images/purescene_canvas1.png

The initial scene is ready now. Below is how you can use the EventSystem 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 the 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 the GUI (Canvas of Button).
_images/purescene_canvas.png
  1. Add the component WaveVR_EventHandler to the Cube
_images/purescene_eventhandler.png

You’re done. You can now play the scene in editor mode to confirm the effect.

Hint: Use Right-Alt + mouse to control the controller in the scene.