Setting up a VR-Enabled Project with Unity and the XR Interaction Toolkit

Tutorial

·

Beginner

·

+10XP

·

10 mins

·

(155)

Unity Technologies

Setting up a VR-Enabled Project with Unity and the XR Interaction Toolkit

In this tutorial, you’ll learn how to configure VR-specific settings in Unity and the XR plug-in for your target XR headset. For a faster start, you’ll apply these settings to the XR Interaction Toolkit example VR project to verify that everything is installed correctly.

Languages available:

1. Setting up a VR-Enabled Project with Unity and the XR Interaction Toolkit

This tutorial has been verified using Unity 2019.4.12f1 LTS, XR Interaction Toolkit 0.9.3-preview, and Oculus XR Plugin 1.4.3


In this tutorial, you’ll learn how to configure VR-specific settings in Unity and the XR plug-in for your target XR headset. For a faster start, you’ll apply these settings to the XR Interaction Toolkit example VR project to verify that everything is installed correctly.


2. Loading the XR Interaction Toolkit Example Project

1. Download XR Interaction Toolkit Examples from GitHub. There are two example projects, each in its own directory, AR and VR.


2. Extract the VR project directory to a location of your choice and, if desired, rename it to something more descriptive, like “XR Interaction Toolkit Example - VR.”


3. In the Projects tab of Unity Hub, add a project, pointing the Hub to the VR project directory.


4. Open the project in Unity.


3. Installing Packages for XR Development

Support for XR hardware is delivered via plug-ins. Plug-ins allow you to develop for a universal XR platform so you don’t need to modify your project for different XR headsets. Supporting new XR hardware is as easy as adding the Plug-in Providers in Project Settings.


Currently, XR plug-ins are available for Oculus, Windows Mixed Reality, and Leap Motion headsets. Also included is the MockHMD plug-in, which allows for XR development without a device. It’s possible to install multiple XR plug-ins to support multiple headsets. In this scenario, the application will look for the headset supported by the first listed loader (covered later in this tutorial). If the headset is not available, the application will search for the next in the list, continuing through all listed loaders in order.


1. Install the following Packages using Package Manager:

XR Interaction Toolkit (Required)
Oculus XR Plugin (for Oculus headsets)
Windows XR Plugin (for Windows Mixed Reality headsets)


2. If prompted, click to remove the OpenVR Desktop Package.


3. Close the Package Manager and open Edit > Project Settings.


4. In the left column, click on XR Plugin Management.


5. Click on the Android tab.


6. Under Plug-in Providers, select for your VR system for each target platform (Figure 01).


Figure 01: Plug-in Providers add support for various XR platforms.

Figure 01: Plug-in Providers add support for various XR platforms.


4. Building and Deploying the XR Interaction VR Example

Finally, we’re ready to build and deploy our project.


1. Load WorldInteraction from Assets > Scenes (Figure 02).


Figure 02: Our demo Scene

Figure 02: Our demo Scene


2. From the File drop-down, select Build Settings.


3. Clear Scenes in Build and click Add Open Scenes.


4. Make sure your target platform is set to Android if targeting Oculus.


5. Click on Player Settings in the lower left corner. In Other Settings, in the Identification section, and set the minimum level to Android 6.0 ‘Marshmallow’ (API level 23). At the time of this writing, this is the current minimum version of Android supported by the XR Interaction Toolkit. If you have your minimum target too low, Unity will advise you of the required minimum.


6. If your XR device is connected and you’d like to test immediately, select it from the Run Device drop-down and click Build and Run (Figure 03). Otherwise, click Build.


Figure 03: Select a connected XR headset for immediate testing.

Figure 03: Select a connected XR headset for immediate testing.


7. You’re now ready to develop and build VR projects in Unity.


5. Conclusion

The XR Interaction Toolkit, paired with the XR plug-in for your chosen device, makes getting started with VR in Unity a breeze.


Complete this tutorial