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?
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?
Please report a bug.
Submitted a bug report. Case: 1215467
Thanks for the advice @Claytonious
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!
@Solovykh
XR Management goes through new APIs.
We have a new Input Features API: Unity - Manual: Unity XR Input
You can get the HMD Input Device, and then call InputDevice.TryGetFeatureValue, with the CommonUsage of UserPresence.
User presence is a boolean. I apologize, this should (and will) be better documented.
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?
Oh right, I read that too fast.
That should be even easier (in pseudocode written in this chat bar):
List devices = new List();
InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.HeadMounted, devices);
bool isPresent = devices.Count > 0;
If a head mounted device is connected, then the device is present.
So, what ⦠the API call XRDevice.isPresent ⦠is now obsolete, and shouldnāt be used at all? If so, shouldnāt that be documented???
This still seems to be broken or undocumented behaviour. @StayTalm_Unity
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.
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, ā¦
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
List<InputDevice> devices = new List<InputDevice>();
InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.HeadMounted, devices);
bool isPresent = devices.Count > 0;
and
XRDevice.isPresent
is always false.
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:
public static bool isPresent()
{
var xrDisplaySubsystems = new List<XRDisplaySubsystem>();
SubsystemManager.GetInstances<XRDisplaySubsystem>(xrDisplaySubsystems);
foreach (var xrDisplay in xrDisplaySubsystems)
{
if (xrDisplay.running)
{
return true;
}
}
return false;
}
Not to mention the fact that the whole concept of sub systems is totally undocumented.
Does this not seem like a step backwards?
XR on unity is a mess!
With Oculus Quest 2 (Oculus Link), itās the opposite for me. itās always true even when i put down the headset
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
UnityEngine.XR.XRDevice.isPresent
is always āfalseā as if there is no device.
Working in Unity 2020.1.11f1 the following code works to detect user presence on the Oculus Rift S, but always returns false on Quest 2:
if (!_headset.isValid) _headset = InputDevices.GetDeviceAtXRNode(XRNode.CenterEye);
_headset.TryGetFeatureValue(CommonUsages.userPresence, out bool present);
As far as the new XR api goes, Iām quite happy with this approach. But the code presented in earlier posts by @StayTalm_Unity and @hrgchris would not be appropriate to be called every frame as it involves instantiating a list of devices. Is there any other efficient and reliable way to check for user presence?
That usage should work on the Quest 2, Iāll ask around internally why user presence isnāt supported.
If you want to just check that a device exists you can get the current list of devices on startup, and then register to the onDeviceConnected callback: https://docs.unity3d.com/ScriptReference/XR.InputDevices-deviceConnected.html
This will notify you of any new devices so you can assume that if there was no HMD on startup, and no callback with an HMD Input Device, there is still no HMD connected. The HMD should always be connected on first frame (Depending on platform it can sometimes be before Awake, sometimes it takes the first Update), because it is the device running the app, but the above is a good practice for āGet All, then Notify of changesā pattern.
Thanks for the reply. I simply want to pause the game while the user isnāt wearing the headset. So, onDeviceConnected isnāt really useful, unfortunately.
Yeah, it sounds like User Presence is definitely what you need.
A few questions:
Have you filed a bug on it? Please do so, and sometimes it can get prioritized better than me nagging a team member.
With Link cable or standalone? Or Both?
When you say itās returning false, is TryGetFeatureValue
returning false, or is present
false after calling that function?
The former means the feature doesnāt exist on the device, the latter means the user is not present.