Virtual Reality
Setup for VR projects & Open XR Support
Ashray Pai
January 2022
Virtual Reality

Setup for VR projects & Open XR Support

Ashray Pai
January 2022
Crucial Mistakes New
XR Devs Must Avoid
Level up your XR coding game
by dodging common mistakes!
Grab yourS NOW

This blog will help you get started with creating VR games using XR Interaction Toolkit in Unity. Also, helpw you setup Unity for using it with HTC Vive or any other OpenXR supported devices.

How to set up Unity for HTC Vive

The latest XR Manager Plugin does not come with OpenXR support. It has to be downloaded separately and installed, which is not that difficult.

The steps mentioned in step 1 and 2 of this post is derived from this YouTube tutorial. If you have the XRInteraction Toolkit and the XRController set up already, you can jump to section 3 which shows how HTC Vive can be used with the OpenXR plugin.

Step 1: Downloading XRInteraction package

This section explains the steps that are to be taken to downloading and import XR Interaction Toolkit into Unity.

  1. Open Unity hub and create and a new Project, I am calling it "Hello VR". It's better to use the Universal Render Pipeline as the template as the graphics will look better on build when compared to 3D template, however you can choose 3D as well.
URP template
  1. Unity will open with a default scene. You can either use the same scene or create a new scene to work with. To create a new scene, select the scene folder in the Project window, right-click on it, Create → Scene. Rename the scene and double click to open.
Creating new scene
  1. OpenXR and XR Interaction toolkit plugins are currently in preview state, which means that it is not a full release and therefore bugs can still be present. Furthermore, it is placed under 'Preview Packages' in the Package Manager. As of now, you have no other option but to use it. To view the preview packages, see the following steps:
    Click on Windows → Package Manager → select the setting icon ⚙ → Advanced Project Setting → Check the box for "Enable Preview Packages" and select I understand. It’s just a warning that it’s a preview package and not yet released so it could potentially have bugs.
Package manager
  1. To import the XR Interaction Toolkit, open package manager → select Unity Registry from the drop-down → search for "XR Interaction Toolkit" or scroll down to find it.
  2. Select that package → Click on See other versions → select 1.0.0-pre.3 and install it.
XRInteraction toolkit
  1. After installing a window will pop up asking you to restart Unity, click on Yes to continue.
XRInteraction toolkit
  1. After Unity restarts, navigate back to the XR Interaction Toolkit package in the package manager. Import Default Input Action and XR Device Simulator
Import samples
  1. This concludes section 1. The next section is to set-up the XR rig and other components to enable us to use VR controllers.

Section 2: Setting up XR Rig

This section explains how the XR rig can be set up with the default key bindings. We have the option to manually assign it but that is a tedious and time-consuming process. So to begin with, it's recommended to use the default setting and later on you can customize the controls.

  1. In the Project window navigate to Samples → XR Interaction Toolkit → 1.0.0-pre.3 → Default Input Actions. Here select "XRI Default Left Controller" and from the inspector window click on Add to ActionBasedController default. Next, select "XRI Default Right Controller" and perform the same action once again.
Default controller
  1. To make sure we get the default values as preset, select File → Build Settings → Player setting → Preset manager, under ActionBasedController type in the filter "Left" and "Right" for the respective presets.
Preset Manager
  1. Delete the Main camera from the Hierarchy. Right-click on the hierarchy window → XR → select Room Scale XR Rig (Action-Based). If you look at the child of the XR Rig you will notice that, both the Left and the Right controllers come with default values now.
XR Rig
  1. Select the XR Rig and add the component Input Action Manager, change the Action Assets list size to 1. In the project window navigate to Samples → XR Interaction Toolkit → 1.0.0-pre.3 → Default Input Actions. Select the "XRI Default Input Actions", drag and drop it in the Input Action Manager component.
XRI Default Input Actions
  1. Add a 3D plane to mark the play area, it’s not necessary but its helps with visualization.
XRI Default Input Actions

This completes the basic setup for developing VR projects. The next section shows the setup of OpenXR

Section 3. Setting up OpenXR Plug-in

The OpenXR plugin was released recently for Unity version 2020. Earlier, developers had to use the older Unity versions for it to be compatible with HTC Vive.

  1. To download and install OpenXR plugin, Click on Windows → Package Manager → Install OpenXR plugin
OpenXR plugin
  1. Navigate to File → Build settings → Player settings → XR Plug-in Management and check the box ☑ for OpenXR.
Enable plugin
  1. In the same window, click on features under OpenXR and check the box ☑ for HTC Vive Controller Profile.
Controller Profile
  1. Note: If you scroll down in the list of features, there is an option of Valve index. I haven't tested that, but if you are an Index user do check that out. It should definitely work.
Index Controller Profile
  1. The last step is to fix a few setup errors. Select the XR Plug-in Management → Click on the exclamation mark → Select the option Fix All.
XR Plug-in Management

With that done, HTC Vive and its controllers can now be used to develop the project.


The Open XR plugin is stable even though it's in the preview version. I didn't face any bugs so far. I'm not sure if this plugin supports other PC VRs, that's something you will have to find out by yourself.

🎉 With that, we have finished setting up Unity to create our VR projects.

Thanks for reading this blog post 🧡

If you've enjoyed the insights shared here, why not spread the word? Share the post with your friends and colleagues who might also find it valuable.

Your support means the world to us and helps us create more content you'll love.

Read more by this author

Continue reading