Virtual Reality — Input and Hand presence

Amulya Reddy Konda
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?

  1. Create empty game object. Rename to HandPresence. Position object to (0,0,0)
  2. Add component → New Script names HandPresence.cs
  3. Add using UnityEngine.XR;
  4. 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);
}
}

--

--