Hey! Im using Unity 2020.3.3f1 and have just thrown a XRRig into my scene, I’ve also made a script that is to loop through all input devices and list their names and characteristics but it does not find any devices to populate my list with, even though if i press play it tracks my headset(Vive) and my controllers(valve index) but it seems i cannot access them in code.
Here is the scrip:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class HandPresence : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
List inputDevices = new List();
InputDevices.GetDevices(inputDevices);
foreach (var device in inputDevices)
{
Debug.Log(device.name + device.characteristics);
}
}
// Update is called once per frame
void Update()
{
}
}
Rather than using Start trying registering for the onDeviceChange callback. The issue may be that the devices arent available yet when start is called.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.InputSystem.html#UnityEngine_InputSystem_InputSystem_onDeviceChange
InputSystem.onDeviceChange +=
(device, change) =>
{
switch (change)
{
case InputDeviceChange.Added:
Debug.Log("Device added: " + device);
break;
case InputDeviceChange.Removed:
Debug.Log("Device removed: " + device);
break;
case InputDeviceChange.ConfigurationChanged:
Debug.Log("Device configuration changed: " + device);
break;
}
};
Since im using the UnityEngine.XR; and not using UnityEngine.InputSystem; that wont work but i moved my code from start() to Update() and then they showed, so as u said they are not loaded by the time start is run, thank you!
OpenXR uses the input system, in fact InputDevice is the input system so that code should work without issue. Moving to the update will work but not as efficient as listening to the events.
Uhm but it i get an error for “InputSystem.onDeviceChange” so i guess i have to include UnityEngine.Inputsystem?
Correct or use UnityEngine.InputSystem.InputSystem.onDeviceChange
sorry for late reply but this will be useful for others…
You can use
using InputDeviceXR = UnityEngine.XR.InputDevice;
hope this help 
OMG u saved my day !!! spending hours for this problem and now all works well with that tip