Buttons (new in SDK 3.0)

Introduction

In previous WaveVR SDK, we provides button event by default.

In new SDK, button event architecture is seperated into prefab WaveVRButtons

Without using WaveVRButtons prefab, developer would not receive any button event.

Resources

Prefab WaveVRButtons locates in Assets/WaveVR/Prefabs/

Script WaveVR_ButtonList locates in Assets/WaveVR/Scripts/

Sample: Assets/Samples/Button_Test/

Prefab

Drag the prefab WaveVRButtons to the scene which needs button events.

The default values of WaveVRButtons are shown as the photo:

_images/WaveVR_ButtonList_01.png

Developer can modify the size to add or remove buttons.

Then developer can receive the events of buttons listed in WaveVRButtons

Developer can refer to WaveVR_Controller for usage of button events.

Sample Code

Set up new button list in runtime

If developer wants to request different button events in runtime:

if (WaveVR_ButtonList.Instance != null)
{
    List<WaveVR_ButtonList.EButtons> _buttons = new List<WaveVR_ButtonList.EButtons> {
        WaveVR_ButtonList.EButtons.DPadDown,
        WaveVR_ButtonList.EButtons.DPadLeft,
        WaveVR_ButtonList.EButtons.DPadRight,
        WaveVR_ButtonList.EButtons.DPadUp
    };

    // button list of Dominant hand.
    WaveVR_ButtonList.Instance.SetupButtonList (WaveVR_Controller.EDeviceType.Dominant, _buttons);
}

Check whether button event is available

If the number of requested button events is more than the number of button in physical device, some button events will not be provided.

E.g. Developer requests 6 events, but device has only 4 buttons – 4 buttons is mapping to 4 events, other 2 events are not available.

Developer has to check whether the button event is available:

// The type (Head / Dominant / NonDominant) of device with buttons.
private WaveVR_Controller.EDeviceType DeviceType = WaveVR_Controller.EDeviceType.Dominant;
// Grip button
private WVR_InputId button_id = WVR_InputId.WVR_InputId_Alias1_Grip;

if (WaveVR_ButtonList.Instance != null      // If prefab WaveVRButtons is not used, instance will be null.
    && WaveVR_ButtonList.Instance.IsButtonAvailable (this.DeviceType, button_id))    // check whether Grip button is available or not.