OpenXR - How to detect when Steam or Rift menu is opened and closed on PC?

With Unity’s XR Plugin Management and OpenXR selected for the runtime, how do I detect when the Steam menu or the Rift menu are opened or closed?

I need to detect this so that I can hide the player’s hand models when the VR system menu is opened.

Note that for the Oculus runtime I can detect when the Universal Menu is opened or closed using these events:

Unity.XR.Oculus.InputFocus.InputFocusAcquired
Unity.XR.Oculus.InputFocus.InputFocusLost

But how can I do this with the OpenXR runtime?

@thep3000 Would you happen to have any insight on this one?

This appears to be the answer for OpenXR Plugin (v1.8.2):

UnityEngine.XR.InputDevices.GetDeviceAtXRNode(XRNode.Head).TryGetFeatureValue(CommonUsages.userPresence, out bool isPresent);

And you need to poll it in an update loop since there isn’t an event to subscribe to. This works to detect when the Steam menu and the Rift menu are opened on PCVR.

They appear to be adding some new ways to check user presence and user focus in newer versions of the OpenXR plugin (via OpenXRUtility.IsSessionFocused and OpenXRUtility.IsUserPresent), but v1.8.2 is the highest version I can install with Unity 2022.3. So, I’ll use the above code for now.

FYI, you can install versions higher than what the unity editor suggests by manually typing in the package manager, for example

com.unity.xr.openxr
1.13.1

This will work fine, it’s just that your specific patch version of 2022 has a ‘pinned’ version and they won’t show you newer versions that would be available in higher patches. That would get you access to those newer APIs.

1 Like

Ah, thank you! I assumed that higher versions were limited in older versions of Unity due to backward compatibility issues, but maybe not?