Testing in VR

Tongyu Zhou, February 2022

There are several ways to test your Unity project in VR, depending on your operating system and the devices you have available. I will be going over 3 main methods, and summarizing my overall experiences with them:

Pre-requisite: To make the setup easier, Unity has provided a Starter Project which contains a lot of the necessary packages installed (XR Plugin Management, XR Interaction Toolkit, OpenXR Plugin), as well as several assets to serve as initial scenes. To follow this guide, I recommend importing this project. You can use this project as a starting base, then add/remove your desired functionalities later. 

Test with the XR Device Simulator

This simulator allows you to test your project directly in the Unity Editor using the mouse and keyboard as your input, instead of connecting to a VR-enabled device. However, you do not get to experience the full ergonomics of the VR setup, so I would only recommend this for light testing or only for internal interaction logic. 

0. Make sure that the XR Interaction Toolkit is installed. Navigate to Window > Package Manager. If you do not see it, click on the gear button next to the search bar > Advanced Project Settings > Enable Preview packages. If you still do not see it, make sure the tab on top is set to Packages: Unity Registry instead of Packages: in Project.


1. Add the XR Simulator to the scene. In the starter project, open Samples > XR Interaction Toolkit > [version] > XR Device Simulator and drag it onto the scene.  Click "Play" to see the simulator in action!


While the simulator has some default key mappings that can be found by double clicking on the .inputactions element within the XR Device simulator (shown on the right), these bindings can be modified by clicking on the old binding a setting the path to a different keyboard or mouse input. 

Test directly in Unity via Oculus Link

Formally, this method actually requires an Oculus Link cable that you have to purchase separately to work at full capacity. However, I still managed to get some testing done with the default charging cable that comes out of the box. With this less optimum charging cable, no VR scene is actually rendered through your headset (you see a black screen), but the 6DOF head movements and controller actions are still captured, so you can still test the VR interactions in-situ, if you don't mind looking at the scene through the Unity preview screen. 

0. Make sure that the Oculus plugin for Desktop testing is installed. This will allow you to create .apk  files (essentially Android apps), which can run on all Oculus Quest devices. If you do not have it installed, install it by adding a module as shown below. Make sure Android SDK & NDK Tools as well as OpenJDK are checked. 


1. Connect and run. Make sure your Oculus is connected to your computer, even if the connection is not necessarily strong. You can check this by opening the Oculus App and clicking on the Devices tab.


Click the Play button on Unity to see your scene! Headset rotational movements as well as controller tracking should be reflected in the Unity scene. 



Test by building and running an apk file

This method allows you to build your project directly into a standalone file that can be run directly on your headset untethered to any external computers. However, depending on your project size, building the file each time can be time-intensive, so I would recommend this for testing bigger features and sharing a working prototype. 

0. Make sure that the Android Build Support module is installed. This will allow you to create .apk  files (essentially Android apps), which can run on all Oculus Quest devices. If you do not have it installed, install it by adding a module as shown below. Make sure Android SDK & NDK Tools as well as OpenJDK are checked. 


1. Install the Oculus Plugin for Android Builds. Navigate to Edit > Project Settings and click on XR Plugin Management from the list. Select the Android tab (the one that looks like a little Android robot) and check Oculus from the list of plugin providers. 


2. Switch to the Android Build and build and run. Navigate to File > Build Settings. In the platform section, select Android. Click Switch Platform, and wait for your project to switch to the Android platform. 


After switching the Android platform, make sure your Oculus is connected to your computer. Now, you should be able to see it on the Run Device drop-down. Select this and click on Build And Run.


After the build is finished, you should be able to disconnect your Oculus and run your application by itself!


Note:  The app is saved in the “Unknown Sources” section of your App Library, so you would need to allow content from unknown sources to run it.