Search Unity

XRDevice.isPresent with XRManagement on Quest

Discussion in 'AR/VR (XR) Discussion' started by Solovykh, Jan 28, 2020.

  1. Solovykh

    Solovykh

    Joined:
    Aug 28, 2017
    Posts:
    59
    Hey,

    It seems like XRDevice.isPresent always returns false on 2019.3.0f6 with the new XR Management system on Oculus Quest. Is that expected?
     
  2. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    727
    Please report a bug.
     
  3. Solovykh

    Solovykh

    Joined:
    Aug 28, 2017
    Posts:
    59
    Submitted a bug report. Case: 1215467

    Thanks for the advice @Claytonious
     
    Last edited: Jan 29, 2020
    AlanMattano and ROBYER1 like this.
  4. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    727
    Thank you for doing that, but don't link to your bug reports on Fogbugz - that exposes *all* of your bug reports to the public, including future ones where you might attach some files or links or info that you don't want to share with the world. Just post the case number itself (in this case, 1215467).

    But thanks again, let's hope it gets fixed now!
     
    Last edited: Jan 29, 2020
    Solovykh likes this.
  5. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    152
    AlanMattano likes this.
  6. Solovykh

    Solovykh

    Joined:
    Aug 28, 2017
    Posts:
    59
    I was under the impression that CommonUsage.userPresence is a replacement for XRDevice.userPresence which tells me if the user is wearing the headset or not. However, XRDevice.isPresent told me if an HMD was connected or not. Is there anything like that with the InputDevice API?
     
  7. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    152
    Oh right, I read that too fast.
    That should be even easier (in pseudocode written in this chat bar):

    List<InputDevice> devices = new List<InputDevice>();
    InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.HeadMounted, devices);
    bool isPresent = devices.Count > 0;

    If a head mounted device is connected, then the device is present.
     
    AlanMattano and Solovykh like this.
  8. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,153
    So, what ... the API call XRDevice.isPresent ... is now obsolete, and shouldn't be used at all? If so, shouldn't that be documented???
     
    shomz likes this.
  9. JurjenBiewenga

    JurjenBiewenga

    Joined:
    Mar 28, 2018
    Posts:
    24
    This still seems to be broken or undocumented behaviour. @StayTalm_Unity
     
    fherbst likes this.
  10. ash_at_unity3d

    ash_at_unity3d

    Unity Technologies

    Joined:
    Jan 9, 2020
    Posts:
    10
    Hey @JurjenBiewenga

    I'm currently looking into this; I'm updating the documentation and API to reflect the appropriate approach as described in this thread.

    I'll update this thread once it's live.
     
  11. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    718
    Please note that the current "undocumented" situation is downright dangerous.

    I just spent two full days debugging total weirdness of one of our applications, and it turns out that with XRManagement active, XRDevice.refreshRate returns 0, while with "Legacy VR" it returns 72. Case 1240243

    Also @ash_at_unity3d it doesn't seem like refresh rate is part of the new xr_input API, or is it just not documented? How do I get the device refresh rate in XR Management? This is important to get frame-perfect physics, smooth animations, ...
     
    AlanMattano and a436t4ataf like this.
  12. JanSelchow

    JanSelchow

    Joined:
    Jul 2, 2020
    Posts:
    1
    Are there any Updates on this. I want to detect if a VR-Headset is connected.
    On unity 2019.4.9f1 i have a WindowsMR Headset connected but both
    Code (CSharp):
    1. List<InputDevice> devices = new List<InputDevice>();
    2. InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.HeadMounted, devices);
    3. bool isPresent = devices.Count > 0;
    and
    Code (CSharp):
    1. XRDevice.isPresent
    is always false.
     
  13. hrgchris

    hrgchris

    Joined:
    Oct 26, 2016
    Posts:
    9
    XRDevice.isPresent is still not marked as deprecated in Unity, so it took me an hour to find this. Are you intending to update.

    Also, I'd just like to voice some concern here. The massive part of the idea of Unity is to be *simple* for users.However according to the docs, the need to call XRDevice.isPresent has been replaced with the need to write the code:

    Code (CSharp):
    1.     public static bool isPresent()
    2.     {
    3.         var xrDisplaySubsystems = new List<XRDisplaySubsystem>();
    4.         SubsystemManager.GetInstances<XRDisplaySubsystem>(xrDisplaySubsystems);
    5.         foreach (var xrDisplay in xrDisplaySubsystems)
    6.         {
    7.             if (xrDisplay.running)
    8.             {
    9.                 return true;
    10.             }
    11.         }
    12.         return false;
    13.     }
    Not to mention the fact that the whole concept of sub systems is totally undocumented.

    Does this not seem like a step backwards?
     
    refardeon likes this.
  14. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,109
    XR on unity is a mess!
     
    JanSelchow likes this.
  15. SunnyChow

    SunnyChow

    Joined:
    Jun 6, 2013
    Posts:
    349
    With Oculus Quest 2 (Oculus Link), it's the opposite for me. it's always true even when i put down the headset
     
  16. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,321
    I do not understand.
    I make a new Project using the VR default Template
    My VR device (Samsung Odyssey) is working fine with Unity 2019.4.18 LTS.
    But
    Code (CSharp):
    1. UnityEngine.XR.XRDevice.isPresent
    is always "false" as if there is no device.
     
unityunity