WaveVR_Utils

Contents

Introduction

This script WaveVR_Utils.cs has many tools.

  • Event

    Register and unregister event listener.

  • Expose of native code

    Native code here is NOT for developer.

  • Pose conversion

    Convert pose from Matrix to Quaternion and position by RigidTransfrom

  • Systrace

    Add Android’s systrace tag in C#.

  • Render thread event handle

    Trigger a render thread event. Not for Developer.

Details

class Event

Event listener can receive event from sender with a listened message. In Event, there are defined event names for different purpose. And also events from WVR_EventType can be listen to.

‘Listen’ the ‘message’ with callback ‘action’ in game object OnEnable, and ‘Remove’ them in OnDisable.

The pre-defined events are

  • DEVICE_CONNECTED

    Listener will receive a device connect stat when a scene is loaded. Even the device didn’t disconnect, the connect stat will send again if scene was loaded. But will not send the disconnected again.

    This event can help show or hide a controller according to its connection stat.

  • NEW_POSES

    Every frame the WaveVR_PoseTracker will receive this event once to update the devices’ pose. You can listen to this event for your purpose.

    This event will be triggered by updatePoses() in WaveVR. In the WaveVR_Render, when a frame is about to render, the updatePoses() will be invoked. And the transform of game object with the WaveVR_PoseTracker will be changed.

  • AFTER_POSES

    After all NEW_POSES was delivered, this event will be sent. Use it for your necessary.

  • ALL_VREVENT

    Every frame the WaveVR_Init will help to poll event by pollEventQueue(). Because the pollEventQueue() should be only used in one place, script which interest with the all VREvents should listen to this ALL_VREVENT.

    Or you can listen to a single event by event types’ name, enum.ToString(). For example:

    WaveVR_Utils.Event.Listen(WVR_EventType.WVR_EventType_RecenterSuccess.ToString(), onSuccss);