How can i use OpenVR api on OpenXR project?

Before, my project used VRIF (VR Interaction Framework), SteamVR plugin, and its built-in OpenVR XR Plugin (v1.1.4) for VR development.

However, since XR Interaction Toolkit (2.3.1) has been released, in order to be more compatible with Unity, we decided to use it to replace our previous plugins. Here are my new plugins:
OpenXR Plugin (1.6.0),
XR Plugin Management (4.3.3),
XR Interaction Toolkit (2.3.1).

I have modified many of the VRIF scripts to XRI, such as Grabber → Interactor, or Grabbable → XRGrabInteractable. The project is basically up and running and has replaced the previous one, but we still encountered some difficult problems:

1: I cannot save the Play Mode OpenXR RunTime, which means users may need to set an additional step in SteamVR, which will cause many users to not understand how to use it.

2: My previous gestures relied on SteamVR_Behaviour, but SteamVR seems to run on OpenVR. However, when I select OpenXR, many OpenVR-related APIs will generate a large number of errors. But when I select OpenVR Loader, many OpenXR functions (such as the controller) will not work.

Is there any relevant solution? Or what should I do?Or may I ask if there is any part of my approach that is incorrect?

Thanks very much

  1. Almost all VR users have just 1 headset, so then the set OpenXR runtime will be set. If someone has multiple headsets on different runtimes, they are probably advanced enough to open the settings

  2. Well, you gotta pick one. OpenVR has some extra features, OpenXR streamlines developmental. While steamvr supports OpenXR, OpenXR cannot run all the same openvr code

1 Like

Hey @feathered_wing ,
As DevDunk pointed out, most users will be only using a single OpenXR runtime. That setting you are pointing to in (1) is actually only relevant for you, the developer. That is just forcing a specific OpenXR runtime to be used anytime you enter play mode in the Unity Editor. On an actual build of your game, it will default to whatever the current active OpenXR runtime is.

  1. I would move forward with only OpenXR if you can manage. I guess it depends on the features you need, but Valve has not updated the OpenVR Loader in over a year (outside of linux support). I know their preference is also likely to be consolidation around a single standard.

What OpenVR errors are you seeing? I wonder if they can be remedied?

1 Like

Thank you very much! As we want to use the constantly updated XR Interaction Toolkit, we will choose to use OpenXR to cover the entire project.

I have done some simple checks, taking gestures as an example with the same code. When I select OpenVR Loader, my OpenVR.Input has a value, but when I select OpenXR, it is null. Skipping this series of checks will also result in null later, which directly affects my finger data, causing my fingers to be straight no matter how I press the controller.

code in
SteamVR_Behaviour.cs 234
8993008--1238326--upload_2023-5-5_11-25-4.png

and SteamVR_Input.cs
8993008--1238329--upload_2023-5-5_11-27-21.png
The position of the gesture control:SteamVR_Input.cs
8993008--1238332--upload_2023-5-5_11-31-27.png
When I remove the checks along the way (such as initialized == null), the following issues arise:
8993008--1238338--upload_2023-5-5_11-36-47.jpeg
8993008--1238335--upload_2023-5-5_11-36-40.png

Thank you very much for your help! I have a rough understanding of problem 1. As for problem 2, we have to use OpenXR because we want to continue to update new features related to the XR Interaction Toolkit in the future.

I am trying to refer to the HandVisualizer in the Hands Interaction Demo to replace the current gestures. Could you please confirm if my approach is correct? Or should I try to replace the parts originally belonging to OpenVR with OpenXR methods?

Yes, I suggest to delete the whole streamvr package and build things up using OpenXR.
But I don’t know how your project is setup

1 Like