場景中拖入Assets\WaveVR\Prefab\WaveVR預製體,刪除默認相機就可以在一體機上進行運行。如果需要顯示手柄則還需要拖入ControllerLoader預製體,建議放在WaveVR預製體下。
獲取手柄按鈕事件則需要再拖入一個WaveVRButton預製體到場景中然後使用以下代碼進行獲取手柄的各個按鈕事件
using UnityEngine;
using UnityEngine.VR;
using UnityEngine.XR;
public class InputEventSystem : MonoBehaviour
{
WaveVR_Controller.Device device;
// Start is called before the first frame update
void Start()
{
device = WaveVR_Controller.Input(wvr.WVR_DeviceType.WVR_DeviceType_Controller_Right);
if (WaveVR_ButtonList.Instance != null)
{
List<WaveVR_ButtonList.EControllerButtons> _buttons = new List<WaveVR_ButtonList.EControllerButtons>
{
WaveVR_ButtonList.EControllerButtons.DPadDown,
WaveVR_ButtonList.EControllerButtons.DPadLeft,
WaveVR_ButtonList.EControllerButtons.DPadRight,
WaveVR_ButtonList.EControllerButtons.DPadUp,
WaveVR_ButtonList.EControllerButtons.Trigger,
WaveVR_ButtonList.EControllerButtons.Menu,
WaveVR_ButtonList.EControllerButtons.VolumeUp
};
// button list of Dominant hand.
WaveVR_ButtonList.Instance.SetupControllerButtonList(WaveVR_Controller.EDeviceType.Dominant, _buttons);
}
}
// Update is called once per frame
void Update()
{
if (device.GetPressDown(wvr.WVR_InputId.WVR_InputId_17))
{
GameObject.Find("Cube").SetActive(false);
}
}
}
下圖對應各個按鈕的定義