Virtual Reality — Input and Hand presence
1 min readJul 12, 2020
Window → Analysis → XR Interaction Debugger → Input Device
Above window shows the input devices.
How to use these inputs in custom component?
- Create empty game object. Rename to HandPresence. Position object to (0,0,0)
- Add component → New Script names HandPresence.cs
- Add
using UnityEngine.XR;
- To get list of devices,
void Start(){
List<InputDevice> devices = new List<InputDevice>();
InputDevices.GetDevices(devices);
foreach(var item in devices){
Debug.log(item.name + item.characteristics);
}
}
5. To get only the right controller instead of entire list,
void Start(){
List<InputDevice> devices = new List<InputDevice>();
InputDeviceCharacteristics rightControllerCharacteristics =
InputDeviceCharacteristics.right |
InputDeviceCharacteristics.Controller;
InputDevices.GetDevicesWithCharacteristics(
rightControllerCharacteristics, devices);
foreach(var item in devices){
Debug.log(item.name + item.characteristics);
}
}