Openxr Unity

  

OpenXR is a plug-in in Unity's XR plug-in architecture. Unity recommends using the XR Interaction Toolkit for input and interactions. If you are using any platform-vendor specific toolkits, please see the platform-vendor specific documentation on how to integrate those toolkits with OpenXR. In Unity 2020, it will become the only XR pipeline in Unity. To get started with the Mixed Reality Toolkit, follow the provided steps to add MRTK to a project. Add XR SDK to a Unity project. Windows Mixed Reality, Oculus, and OpenXR are supported on XR SDK. Required in Unity OpenXR.

  1. Openxr Oculus Quest 2
  2. Openxr Unity Hololens
  3. Openxr Unity Hololens
-->

While we currently recommend installing Unity 2019.4 LTS and using Legacy Built-in XR for Mixed Reality development, you can build apps with other Unity configurations as well.

Unity 2019.4 LTS (Recommended)

Microsoft’s current recommended Unity configuration for HoloLens 2 and Windows Mixed Reality development is Unity 2019.4 LTS using Legacy Built-in XR support.

The best way to install and manage Unity is through the [Unity Hub]. When it's installed, open Unity Hub:

  1. Select the Installs tab and choose ADD
  2. Select Unity 2019.4 LTS and click Next
  1. Check following components under 'Platforms'
    • Universal Windows Platform Build Support
    • Windows Build Support (IL2CPP)
  1. If you installed Unity without these options, you can add them through 'Add Modules' menu in Unity Hub:

To get started with Legacy Built-in XR in Unity 2019.4 LTS, click here:

Note

Unity has deprecated its Legacy Built-in XR support as of Unity 2019. While Unity 2019 does offer a new XR Plug-in framework, Microsoft is not currently recommending that path in Unity 2019 due to Azure Spatial Anchors incompatibilities with AR Foundation 2. In Unity 2020, Azure Spatial Anchors is supported within the XR Plug-in framework.

If you are developing apps for HoloLens (1st gen), these headsets remain supported in Unity 2019 LTS with Legacy Built-in XR for the full lifecycle of Unity 2019 LTS through mid-2022.

Unity 2020.3 LTS

If you’re using Unity 2020.3 LTS, you can use the Windows XR plugin to develop HoloLens 2 and Windows Mixed Reality applications.

However, there are known issues that affect hologram stability and other features on HoloLens 2:

Openxr
  • Depth buffer submission has regressed in recent Unity 2020 builds, which results in severe hologram instability.
  • Holographic app remoting applications using the Universal Windows Platform build target are not working.
  • The Unity graphics jobs system is defaulted on, even though it is not compatible with HoloLens projects.

If you choose to start a new project in Unity 2020 today, be sure to follow up over the coming months for updated Unity builds and Windows XR plugin builds before shipping your app. This will ensure that your users experience proper hologram stability.

Using OpenXR

Unity 2020.3 LTS also supports a public preview of the Mixed Reality OpenXR plugin.

The Mixed Reality OpenXR plugin fully supports AR Foundation 4.0, providing ARPlaneManager and ARRaycastManager implementations. This enables you to write hit-testing code once that then spans HoloLens 2 and ARCore/ARKit phones and tablets.

Later this year, Unity 2020.3 LTS with the OpenXR plugin will become the recommended Unity configuration, and future HoloLens 2 features in Unity will be exposed only through this plugin. You can start your project here for now - however, if your project targets HoloLens 2, you will currently encounter the Unity 2020 hologram stability and other issues listed above. Be sure to check back in the coming months for updated Unity builds and OpenXR plugin builds before shipping your app. This will ensure that your users experience proper hologram stability.

Unity 2021.1

If you are trying out early Unity 2021.1 builds, you should move forward to the OpenXR plugin, as the Windows XR plugin is deprecated there. Starting in Unity 2021.2, the OpenXR plugin will be the only path for Mixed Reality development, as the Windows XR plugin will no longer be supported.

Unity 2018.4 LTS

If you already have a project using Unity 2018.4 LTS, your Unity engine continues to be supported for 2 years after its release. Unity 2018 LTS will reach end of service in the spring of 2021.

OpenXR is an open, royalty-free standard developed by Khronos that aims to simplify AR/VR development by allowing developers to seamlessly target a wide range of AR/VR devices.

Requirements

This version of OpenXR is compatible with the following versions of the Unity Editor:

  • 2020.2+

Supported platforms

Unity's OpenXR plug-in should work with any device that supports conformant PC-based OpenXR runtimes. The following platforms have been fully tested and are officially supported:

PlatformBuild targetGraphics APIRendering mode
Windows Mixed RealityWindowsDX11Single Pass Instanced
HoloLens 2UWPDX11Single Pass Instanced

At this time, deploying directly to Oculus Quest/Quest 2 is not supported.

Unity plans to expand the number of supported platforms in the future as more of our platform partners adopt the OpenXR standard. However, given the unbounded combinations of possible hardware/software configurations, Unity is unable to test or guarantee that all configurations will work optimally. To help the community as a whole, Unity will continue to submit any runtime issues, and contribute conformance tests and specification changes to the Khronos working group.

Getting started

To enable OpenXR in your project, follow the steps below:

  1. Install the OpenXR Plugin package from Package Manager.
  2. Open the Project Settings window (menu: Edit > Project Settings), and select XR Plug-in Management.
  3. Enable the OpenXR option and any Feature Sets for the runtimes you intend to target.
  4. In the OpenXR > Features tab, select the interaction profile of the device you are testing with.
  5. In the OpenXR tab, make sure the current active runtime is set to the hardware you are testing with. See the Per-platform setttings section on this page for more information.

Openxr Oculus Quest 2

Project validation

Unity raises errors and warnings at build time if your project is not compatible with OpenXR. Make sure that your project conforms to the following rules and standards:

  • The Color Space must be set to Linear in the Player settings (menu: Edit > Project Settings > Player, then select your platform and change this setting under Other Settings > Rendering). OpenXR does not support Gamma color space rendering in Unity.

  • You must select at least one interaction profile in the OpenXR tab. Unity's OpenXR plug-in includes several interaction profiles, and you can add more from the Features tab. For more information on interaction profiles, see the OpenXR input page.

Unity

Features might introduce new validation steps. For more information, refer to specific feature documentation. Unity does not write or maintain documentation for third-party features, nor does Unity guarantee that any third-party documentation is correct or complete.

Unity reports validation issues in the following locations:

  • XR Plug-in Management window: Icon next to the OpenXR loader.
  • Features pane: Icon next to the feature set containing the feature that is reporting a validation issue.
  • Features pane: Icon next to each feature that is reporting a validation issue.
  • Console window, as the result of a build: Validation errors cause the build to terminate. Validation warnings do not terminate the build.

Validation issues reported in XR Plug-in Management

Clicking on either the validation warning or the error icon brings up the Validation window.

Validation issues reported in features pane

Clicking on either the validation warning or the error icon brings up the Validation window.

Validation issues reported in build

Double-clicking on build warnings or errors from validation brings up the Validation window.

Troubleshooting

If you experience an issue, please file a bug. When you do, please also check the log file to see if Unity supports the combination of OpenXR runtimes and features you are using. The log file will provide additional guidance.

Unity generates a diagnostic log in either the Player or Editor log, depending on where you run the application. The diagnostic log starts with Start Unity OpenXR Diagnostic Report and ends with End Unity OpenXR Diagnostic Report log entries. It contains information about your application, Unity version, OpenXR runtime, OpenXR Extensions, and other aspects that can help diagnose issues.

The most important part of the diagnostic log is the section marked OpenXR Support Details . This section provides some simple information on what parts of your application Unity supports, what it might not support, and what to do before submitting an issue or requesting assistance.

Examples

Diagnostic log OpenXR Support Details section when running with Unity supported items

Diagnostic log OpenXR Support Details section when running with items not supported by Unity

Known issues

  • Deploying directly to Oculus Quest/Quest 2 will be released at a later date.
  • A black box appears in upper-right quadrant when running in Oculus desktop. An updated Oculus runtime will be released which fixes this. In the meantime, you can turn off occlusion mesh for the built-in renderer.
  • Eye Tracking Interaction device layout does not appear in the Unity Input System menus.
  • Haptics is currently not supported. It will be added in a later version of the OpenXR plug-in.
  • An issue with an invalid stage space during startup may cause problems with the XR Rig component from the com.unity.xr.interaction.toolkit package, or the camera offset component in the com.unity.xr.legacyinputhelpers package. These packages will be updated shortly to contain fixes for this issue. Until then the workaround is to use the Floor Device Tracking Option setting.

Upgrading a project to use OpenXR

OpenXR is a plug-in in Unity's XR plug-in architecture. Unity recommends using the XR Interaction Toolkit for input and interactions. If you are using any platform-vendor specific toolkits, please see the platform-vendor specific documentation on how to integrate those toolkits with OpenXR. Vendors are still in the process of adding OpenXR support to their toolkits; please make sure you check supported status before enabling OpenXR in your project.

The core steps to upgrade a project to use OpenXR are the setup instructions at the top. In addition, you might need to do some of the following:

  1. Update to the latest supported version of Unity before implementing OpenXR. Some APIs that your project relies on might have been changed or removed, and this will let you easily distinguish which changes are a result of the new Unity version and which come from OpenXR.
  2. Disable XR SDK plug-ins that are also supported by OpenXR. There is a good chance that OpenXR supports your target device, so enabling a competing XR SDK plug-in may cause unexpected behavior. In Project Settings > XR Plug-in Management, uncheck the plug-in provider(s) for your target device(s).
  3. Update your input code if your project doesn't use the new Input System. For more information, see the Quick start guide in the Input System package documentation.
  4. Change quality settings. It is possible that switching over to the OpenXR provider will affect your application's visual quality. You can adjust the quality settings of your project (menu: Edit > Project Settings > Player, then select the Quality tab) to try getting your old visuals back.

OpenXR concepts

Understanding OpenXR's action-based input

See OpenXR Input Documentation.

Generic OpenXR Settings

Settings supported on all platforms

The following settings are general across all platforms in OpenXR:

Render Mode - Sets the requested render mode for a given platform. You can choose from the following:

OptionDescription
Multi PassWhen rendering, the engine will do a complete render pass (culling and rendering) for each eye.
Single Pass InstancedWhen rendering, the engine will do simultaneous renders to each eye using shared culling and a single render pass.

Depth Submission Mode - Sets the requested depth submission mode for a given platform. You can choose from the following:

OptionDescription
NoneNo depth submission support. No depth based stability or re-projection support that the platform my provide will be available.
Depth 16 bitA shared depth buffer using 16 bits per pixel will be used.
Depth 24 bitA shared depth buffer using 24 bits per pixel will be used.

Per-platform settings

Standalone:

Active OpenXR Runtime - Sets the OpenXR runtime to be used when running your app in Play mode. This setting is only active for the current running instance of the Editor that you are using. You can choose from the following:

OptionDescription
System DefaultThe currently set OpenXR runtime.
Windows Mixed RealityIf available, sets the current OpenXR runtime to the Microsoft OpenXR runtime for Windows Mixed Reality.
SteamVRIf available, sets the current OpenXR runtime to the SteamVR OpenXR runtime.
OculusIf available, sets the current OpenXR runtime to the Oculus OpenXR runtime.
OtherAllows you to navigate to and select the json file for a specific runtime. Useful when you want to use an OpenXR runtime that Unity might not directly support or detect automatically.

OpenXR features

Features allow third parties to extend Unity's base support for OpenXR. They bring the functionality of OpenXR spec extensions to the Unity ecosystem, but Unity is not involved in their development.

Features might integrate into the Unity XR Plug-in framework to provide data to other XR subsystems (for example, providing meshing or plane data for AR use cases which are not yet standardized in OpenXR 1.0).

Features are a collection of Unity Assets that can be distributed through the Package Manager, Asset Store, or any other mechanism.

Feature selection and configuration

You can enable, disable, and configure features from the Features tab in the XR Plug-in Management > OpenXR window. The window has two main sections: Feature Sets in the left pane, and Features that a feature set supports in the right pane.

Feature sets are a grouping of features that a provider defines. Use them to easily select and group a number of features. Selecting a feature set in the left pane filters the set of features on the right to only the features that the set contains. You can then enable or disable these features individually.

The right pane provides the following information for each feature:

  • Name
  • Category, which can be one of the following:
    • Feature - Category for general features.
    • Interaction - Category for features that provide specific support for input or other interaction devices.
  • Author, which can be a person, team, or company
  • Version
  • Settings - If the feature has any custom settings, you can configure these here.

OpenXR core features

General features

  • Mock Runtime (Note: Enabling this will take over whatever current OpenXR runtime you might be using.)
  • Eye Tracking Support

Interaction profile features

  • Microsoft Hand Interaction Support
  • HTC Vive Controller Support
  • Khronos Simple Controller Support
  • Microsoft Motion Controller Support
  • Oculus Touch Controller Support
  • Valve Index Controller Support

Accessing features at runtime via script

You can also access all the settings in the Features window through script. The scripting API documentation in this package provides information on all APIs you can use for feature support. The code samples below illustrate some of the common tasks.

Iterating over all features

Openxr Unity Hololens

Getting a specific feature by type

Iterating over all feature sets

Feature sets are an Editor-only concept and as such can only be accessed in the Unity Editor.

Iterating over features in a feature set

Openxr Unity Hololens

Feature sets are an Editor-only concept and as such can only be accessed in the Unity Editor.

Implementing a feature

Anyone can add new features. To learn more, see documentation on how to add a feature to Unity's OpenXR support.

References