WaveVR_ControllerLoader

Old version (2.1.8 and before): here

Old version (2.1.2 and before): here

Old version (2.0.25 and before): here

Contents

Introduction

WaveVR_ControllerLoader is a generic controller loader which will dynamically load the controller model and its behavior through settings and runtime environment variables. It will load FBX, assetbundles, or client resources with priority by different SDK version, developer doesn’t need to redesign the controller model to support another device. WaveVR will initialize the proper model when a different device is used. Precondition is controller provider need to follow rules by WaveVR, please refer to How to make controller model

Controller loader provides many settings for developer to select. The settings include:

  • Type

Controller type, it is either Dominant or NonDominant.

  • Controller Components

This means how many components are available in the controller model. It is either one or multiple (default) components. If you need to have a response for each button, please use multiple components. (Deprecated)

  • Tracking Position

Developer can select options.

_images/cl_trackingmethod.png

If Track Position is checked, Simulate Position options will show.

If Simulate Position is selected as When No Position or Force Simulation, Follow Head checkbox will show.

Follow Head means that when controller is put (on table or whatever), controller should follow head movement or not in scene.

Note: the head position which controller follows is localPosition, not world position. Refer to Pose Tracker

  • Controller Model

Developer can select options.

  • Adaptive loading

Controller loader will load controller model from device service if this option is checked, otherwise controller loader will load controller model from SDK/package. If developer checked this option, WaveVR_ControllerLoader will provide more options about button effect, beam, controller pointer and indication feature to you. default is true.

_images/cl_adaptiveLoading.png

Once Adaptive loading enabled, there are more options provided to developer.

Emitter:

The loaded controller will be able to show beam, pointer and send button event. If Enable emitter is checked, developer is still able to decide if each of beam/pointer/event is active or not, If Enable emitter is not checked, all of beam/pointer/event are deactivated.

_images/cl_event.png

Event

If the loaded controller is able to send button event.

Beam:

_images/cl_beam.png
  • Show beam

If the loaded controller will show beam, if show beam, the following options are listed:

  • Apply system config

If this option is checked, beam length and color is defined by system config. default is checked.

If Apply system config isn’t checked, controller loader will provide more options to developer as

  • Need to update every frame

The beam will update every frame if checked. default is false.

  • Start offset

Beam will show ahead of controller model, default is 0.015f.

  • Start width

Beam width of start side, default is 0.000625f.

  • End offset

Beam length, default is 0.65f.

  • End width

Beam width of end side, default is 0.00125f.

  • Use default material

The beam will use material provided by WaveVR SDK. default is checked and choose start/end color.

  • Start color

Beam color of start side, default is 0xFFFFFFFF.

  • End color

Beam color of end side, default is 0xFFFFFFFF.

If Use default material isn’t checked, developer will select Custom material and beam will apply this material. Developer is able to use it to design your preferred beam style.

Controller pointer:

_images/cl_pointer.png
  • Show controller pointer

If the loaded controller will show controller pointer, if show controller pointer, the following options are listed:

  • Apply system config

If this option is checked, controller pointer is defined by system config. default is checked.

If Apply system config isn’t checked, controller loader will provide more options to developer as

  • controller pointer will blink

The controller pointer will blink if checked. default is false.

  • Minimum pointer diameter

Minimum pointer, default is 0.01f.

  • Use default pointer texture

The controller pointer will use texture provided by WaveVR SDK. default is checked.

If Use default pointer texture isn’t checked, developer will select Custom pointer texture. Developer is able to use it to design your pointer image.

Button effect:

_images/cl_effect.png
  • Enable button effect

If this option is checked, button effect is show when key is pressed. default is checked.

  • Apply system config

If this option is checked, button effect color is defined by system config. default is checked.

  • Button effect color

If Apply system config isn’t checked, button effect color is defined by developer setting.

Indication feature:

Theremore, WaveVR_ControllerLoader will show indicator of controller model if the model supports, and provides following parameters to let developer customize your model:

_images/cl_indicator.png
  • Show Indicator

Enable indicator feature, default value is false.

If Show Indicator is checked, controller loader will provide more options to developer as

  • Use system config

If this option is checked, button tips and all settings use system defined. default is checked. If Use system config isn’t checked, more options are listed:

  • Indicator based on emitter

Indicator is based on emitter, default is true.

  • Hide Indicator when roll angle > 90

Hide indicator if controller roll angle is more than 90. default is true.

  • Show Indicator Angle

Show indicator when controller pitch angle, default value is 30.

Line customization:

  • Line Length

Line length between button and indicator, default value is 0.03f and range is 0.01f - 0.1f.

  • Line Start Width

Starting width of line, default value is 0.0004f and range is 0.0001f - 0.1f.

  • Line End Width

Ending width of line, default value is 0.0004f and range is 0.0001f - 0.1f.

  • Line Color

Line color, default value is white.

Text customization (This used textMesh of Unity):

  • Text Character Size

Non-chinese character size of text, default value is 0.08f,range is 0.1f - 0.2f.

  • Chinese Character Size

Chinese character size of text, default value is 0.07f,range is 0.1f - 0.2f.

  • Text Font Size

Font size of text, default value is 100f,range is 50 - 200f.

  • Text Color

Text color, default value is white.

Button indication:

Developer uses a list to show button indication, each item includes

  • Key Type

WaveVR_ControllerLoader supports button include

  1. TriggerKey
  2. Touchpad
  3. DigitalTriggerKey
  4. AppButton
  5. HomeButton
  6. VolumeKey
  7. VolumeUp
  8. VolumeDown
  9. Grip
  10. DPad_Left
  11. DPad_Right
  12. DPad_Up
  13. DPad_Down
  • Alignment

Indication should present on which side, default value is right.

  • Indication offset

Indication default computed by origin of game object, developer might use this offset value to adjust position.

  • Use Multi-language

If checked, indication text will show by locale. How to use multi-language, please refer to WaveVR_Resource

  • Indication text

If Use Multi-language isn’t checked, the content used to present, developer might use keyword “system” to show content of Key Type defined by system.

  • Indication key

If Use Multi-language is checked, the key used to query system resource, developer might use keyword “system” to query resource by defined key-name, or use custom key-name to query resource.

  • Follow Button Rotation

The indication follows button’s rotation, default is false.

Finally, controllerLoader will broadcast CONTROLLER_MODEL_LOADED event with device type and controller instance to all when the controller model loads successfully. Please monitor this event if you need to get the controller instance to proceed or customize. Moreover, controllerLoader will broadcast CONTROLLER_MODEL_UNLOADED event when controller is disconnected.

Resource

Prefab ControllerLoader is located in Assets/WaveVR/Prefabs

Script WaveVR_ControllerLoader.cs is located in Assets/WaveVR/Scripts

Reference scene ControllerLoader_Test is located in Assets/Samples/ControllerLoader_Test (in wvr_unity_samples.unitypackage)

Generic controller models are located in Assets/WaveVR/Extra/GenericModel

How to Use

Prefab usage

Since there are so many options, we won’t demonstrate thoese photo by photo.

Usage is very simple:

  1. Drag the prefab ControllerLoader into your scene and rename to whatever you like.
  2. Select Type.
  3. Select position and/or rotation tracking options. Already described above in Introduction part.
  4. Keep system setting for other options.

How to monitor CONTROLLER_MODEL_LOADED/UNLOADED event

Broadcast event is activated after WaveVR is initialized and only works on the device.

void OnEnable()
{
    WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.CONTROLLER_MODEL_LOADED, fun1);
    WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.CONTROLLER_MODEL_UNLOADED, fun2);
}

private void fun1(params object[] args)
{
    var _dt = (WVR_DeviceType)args[0];
    var go = (GameObject)args[1];
}

private void fun2(params object[] args)
{
    var _dt = (WVR_DeviceType)args[0];
}

If you want to know when a controller is loaded in play mode, implement WaveVR_ControllerLoader.onControllerModelLoaded delegate. See the example below. The go parameter is a controller instance generated by the controller loader.

public delegate void ControllerModelLoaded(GameObject go);

void OnEnable()
{
    #if UNITY_EDITOR
    WaveVR_ControllerLoader.onControllerModelLoaded += controllerLoadedHandler;
    #endif
}

void OnDisable()
{
    #if UNITY_EDITOR
    WaveVR_ControllerLoader.onControllerModelLoaded -= controllerLoadedHandler;
    #endif
}

void controllerLoadedHandler(GameObject go)
{
    Debug.Log("controllerLoadedHandler : " + go.name);
}