Search Unity

Question Easiest way to know if a VR device is connected

Discussion in 'XR Interaction Toolkit and Input' started by LJ3N, Jul 2, 2021.

  1. LJ3N

    LJ3N

    Joined:
    May 8, 2020
    Posts:
    5
    Hello,

    I am currently working on an application using OpenXR. I wanted to be able to start the appliation in desktop mode when no VR device is found. I tried to achieve that using UnityEngine.XR.InputDevices.

    Code (CSharp):
    1.  
    2.         var inputDevices = new List<UnityEngine.XR.InputDevice>();
    3.         UnityEngine.XR.InputDevices.GetDevices(inputDevices);
    4.         Debug.Log(inputDevices.Count);
    5.  
    6.  
    7.         foreach (var device in inputDevices)
    8.         {
    9.             Debug.Log(string.Format("Device found with name '{0}' and role '{1}'", device.name, device.characteristics.ToString()));
    10.         }
    11.  
    Problem is that when I start the application in the Editor whith my HP Reverb G2 connected it starts correctly using the headset but my list of input device is empty. Did I miss something or is there a simpler way to do that ?
     
  2. the_real_apoxol

    the_real_apoxol

    Unity Technologies

    Joined:
    Dec 18, 2020
    Posts:
    467