How To Install And Enable XR Interaction Toolkit For VR Development
Unity’s XR Interaction Toolkit (XRI) is an optional Unity Package that comes with Components to help set up interactions in VR and AR, including device tracking, input, gestures, locomotion, UI & object interaction.
In the first part you’re going to learn how to install the XRI inside Unity while in the second part you’ll learn how to enable it and pair it with your VR headset and unlock its full functionality.
Enabling XR Interaction Toolkit for VR Development
Before you start developing VR experiences you should know what devices you want your application to support and have a project started (Oculus, Magic Leap, Playstation VR etc..). Now you need to enable XR in Unity to build and test your application for those particular devices.
By the end of this tutorial, you should be able to play-test your game with the supported devices.
- Before opening your Project, you may have to install modules for the devices you want to support.
In the Unity Hub, go to the Installs section. On your version of Unity, click the Settings button.
Select Add modules.
Just check the platforms you want to support and click Continue to install them.
Note: Oculus Quest standalone requires Android support.
You can view the supported XR platforms here.
2. With your project open, lets install the XR Plug-in Manager
Go to the package manager.
Go to the Unity Registry dropdown option in the top left corner.
At the bottom of the list, you will find the XR Plugin Management package. This package allows our project to support multiple devices.
Click Install in the bottom right corner.
3. Next we will enable our supported devices.
Navigate to the Project Settings window. You’ll find it under Edit > Project Settings.
At the bottom of the left-side list, you will see XR Plug-in Management.
Here you will see your supported platforms and you can choose what you want to support.
I recommend you install and use the AR Foundation for both ARKit and ARCore. You can get it from the Package Manager Unity Registry. (You will still want to enable the ARCore and/or ARKit platforms below.) To learn more about different types of AR plugins (or AR SDKs), check out a comprehensive AR Comparison Guide.
Note: There are normally two ways to test your project: Directly from the Unity Editor, or by creating a build (Executable stand-alone application). By default, you can not test ARCore and ARKit applications directly from the Unity Editor.
There are some paid resources out there to help accomplish this:
Unity MARS - 45-day free trial, then $50/month.
AR-Foundation-Editor-Remote - One-time $80 purchase.
But otherwise, you have to build the project onto the devices to test them.
How to build to ARCore devices.
Most ARCore devices require checking ARCore in the Android Tab.
How to build to ARKit devices.
ARKit is for iOS devices. Check it in the iOS Tab.
Most other platforms, like Magic Leap & Windows Mixed Reality (Hololens & more) can be checked in the Windows tab.
Magic Leap - Can be tested using Zero Iterations.
Hololens - Can be tested using Microsoft’s Hololens Emulator.
As an Oculus developer, I recommend you use Oculus Link to test your game from the Unity Editor.
Oculus Quest 1 and 2
Check Oculus in the Android tab.
Check Oculus in the Window tab.
OpenXR Supports most other common VR devices, such as Valve Index & HTC Vive.
Once installed, you may get a prompt asking to enable the new input system. OpenXR requires this to be enabled. I recommend clicking Yes.
If you click on the Warning Symbol next to OpenXR, it will open up a Project Validation window where you can fix some issues.
For the first Issue, in order to have an xr controller support, you need to add an Interaction Profile. Click on the plus symbol (+) to view the available profiles and choose the options for the devices you want to support.
And that’s it. With this setup you’ll be able to test the applications inside Unity faster.
Installing XR Interaction Toolkit in Unity
First, open Unity and click on Window in the navigation bar.
Find and click on Package Manager.
Under packages, change the selection from In Project to Unity Registry.
You will find the XR Interaction toolkit in the Unity Registry, at the bottom of the list.
If it is there, click Install in the bottom right.
Warning: If the XR Interaction Toolkit is not there, you may have to manually add it by clicking on the + in the top right and selecting “Add Package by name…” and entering com.unity.xr.interaction.toolkit as the name.
Once installed, you may get a prompt asking to enable the new input system. Click Yes.
We will also want to add the Starter Assets Sample pack from the XR interaction Toolkit. These assets include Action-based input that make it easier to get started on a project.
Download XR Development with Unity Course Syllabus