Getting started with MRTK2 and XR SDK
XR SDK is Unity's new XR pipeline in Unity 2019.3 and beyond. In Unity 2019, it provides an alternative to the existing XR pipeline. In Unity 2020, it's the only XR pipeline in Unity.
Configuring Unity for the XR SDK pipeline
The XR SDK pipeline currently supports 3 platforms: Windows Mixed Reality, Oculus, and OpenXR. The sections below will cover the steps needed to configure XR SDK for each platform.
Windows Mixed Reality
Go into Unity's Package Manager and install the Windows XR Plugin package, which adds support for Windows Mixed Reality on XR SDK. This will pull down a few dependency packages as well.
Ensure that the following all successfully installed:
- XR Plugin Management
- Windows XR Plugin
- XR Legacy Input Helpers
Go to Edit > Project Settings.
Click on the XR Plug-in Management tab in the Project Settings window.
Go to the Universal Windows Platform settings and ensure Windows Mixed Reality is checked under Plug-in Providers.
Ensure that Initialize XR on Startup is checked.
(Required for in-editor HoloLens Remoting, otherwise optional) Go to the Standalone settings and ensure Windows Mixed Reality is checked under Plug-in Providers. Also ensure that Initialize XR on Startup is checked.
(Optional) Click on the Windows Mixed Reality tab under XR Plug-in Management and create a custom settings profile to change the defaults. If the list of settings are already there, no profile needs to be created.
Oculus
- Follow the How to configure Oculus Quest in MRTK using the XR SDK pipeline guide to the end. The guide outlines the steps needed to configure both Unity and MRTK to use the XR SDK pipeline for the Oculus Quest.
OpenXR
Important
OpenXR in Unity is only supported on Unity 2020.2 and higher. It also only supports x64, ARM, and ARM64 builds.
Follow the Set up a new OpenXR project with MRTK instructions to add the OpenXR plug-in to your project. Ensure that the following have successfully installed:
- XR Plugin Management
- OpenXR Plugin
- Mixed Reality OpenXR Plugin
Go to Edit > Project Settings.
Click on the XR Plug-in Management tab in the Project Settings window.
Ensure that Initialize XR on Startup is checked.
(Optional) If targeting HoloLens 2, make sure you're on the UWP platform and select "Microsoft HoloLens feature group".
(Optional) If targeting Quest 2, make sure you're on the Android platform and select "Hand Tracking" and "Meta Quest Support".
Note
If you have a pre-existing project that is using MRTK from UPM, make sure that the following line is in the link.xml file located in the MixedRealityToolkit.Generated folder.
<assembly fullname = "Microsoft.MixedReality.Toolkit.Providers.OpenXR" preserve="all"/>
Configuring MRTK for the XR SDK pipeline
Use any of the default MRTK profiles, which are all configured across Unity's XR pipelines. The previous "DefaultOpenXRConfigurationProfile" and "DefaultXRSDKConfigurationProfile" are now labeled obsolete.
If using OpenXR, choose "DefaultOpenXRConfigurationProfile" as the active profile or clone it to make customizations.
If using other XR runtimes in the XR Plug-in Management configuration, like Windows Mixed Reality or Oculus, choose "DefaultXRSDKConfigurationProfile" as the active profile or clone it to make customizations.
These profiles are set up with the correct systems and providers, where needed. See the profiles docs for more information on profile and sample support with XR SDK.
To migrate an existing profile to XR SDK, the following services and data providers should be updated.
You will be able to see the new data providers under the XR SDK tab in Unity 2019, or in the main/only view in Unity 2020+, where legacy XR doesn't exist.
Camera
Add the following data providers
OpenXR Plugin | Windows XR Plugin |
---|---|
XRSDK.OpenXR.OpenXRCameraSettings |
XRSDK.WindowsMixedReality.WindowsMixedRealityCameraSettings |
GenericXRSDKCameraSettings |
GenericXRSDKCameraSettings |
OpenXR Plugin | Windows XR Plugin |
---|---|
XRSDK.WindowsMixedReality.WindowsMixedRealityCameraSettings |
|
GenericXRSDKCameraSettings |
GenericXRSDKCameraSettings |
Input
Add the following data providers
OpenXR Plugin | Windows XR Plugin |
---|---|
OpenXRDeviceManager |
XRSDK.WindowsMixedReality.WindowsMixedRealityDeviceManager |
OpenXR:
Windows Mixed Reality:
Boundary
Add the following data providers
From MixedRealityBoundarySystem
to
OpenXR Plugin | Windows XR Plugin |
---|---|
XRSDKBoundarySystem |
XRSDKBoundarySystem |
Spatial awareness
Add the following data providers
OpenXR Plugin | Windows XR Plugin |
---|---|
XRSDK.OpenXR.OpenXRSpatialAwarenessMeshObserver (for UWP) |
XRSDK.WindowsMixedReality.WindowsMixedRealitySpatialMeshObserver (for UWP) |
XRSDK.GenericXRSDKSpatialMeshObserver (for non-UWP) |
OpenXR Plugin | Windows XR Plugin |
---|---|
XRSDK.GenericXRSDKSpatialMeshObserver |
XRSDK.WindowsMixedReality.WindowsMixedRealitySpatialMeshObserver |
Controller mappings
If you're using custom controller mapping profiles, open one of them and run the Mixed Reality Toolkit -> Utilities -> Update -> Controller Mapping Profiles menu item to ensure the new XR SDK controller types are defined.