Using the Oculus Quest 2 wirelessly for Unity with Virtual Desktop

Thomas Steffen
4 min readMar 17, 2021

--

Normally, you would have to test your program with the wired USB connection by navigating to the Build Settings, locate Platform, select Android, then setting Run Device to Oculus.

A major problem with this method is that sometimes your connection can be lost, this could be due to pulling on the wire, an older wire, the headset shutting off, or anything else that can cause a disconnect. Once you reconnect your device, Unity may not recognize it unless you exit out of Unity and reload your project. You can imagine how frustrating this can quickly become when frequently testing/running your scene.

Wouldn’t it be a lot easier to put your wireless headset on, hit the play button in Unity, and test your application just like any other non-vr app you’ve developed?

To get started, you will need to purchase Virtual Desktop from the Oculus store. This is normally priced at $19.99. For purposes outside of Unity, Virtual Desktop can be very useful for remote use and to even access and play your Steam VR library/games wirelessly. You should install this on your headset, as well as the desktop version(free) on your PC.

In this example, I am using Unity version 2019.4.20f1. I have downloaded and installed the Oculus Integration package found on Unity Asset Store or at https://developer.oculus.com/downloads/package/unity-integration/.

In Unity, Enable Virtual Reality (VR) Support

Use XR Plugin Framework (only available in Unity versions 2019.3 and higher):

  1. From the menu, go to Edit > Project Settings.
  2. From the left navigation pane, select XR Plugin Management, and click Install XR Plugin Management.
  3. Click the Android tab and select Oculus to install the Oculus XR plugin, which enables the VR support.
  4. From the left navigation pane, under XR Plugin Management, click Oculus to open and modify the default settings.

Set your Oculus device into developer mode:

  1. Turn on the headset you want to use for development.
  2. Open the Oculus app on your phone and go to Settings.
  3. Tap the device and go to More Settings > Developer Mode.
  4. Slide the Developer Mode toggle.
  5. Connect your headset to the computer using a USB-C cable and wear the headset.
  6. Accept Allow USB Debugging and Always allow from this computer when prompted on the headset.

You’ll want to make sure you’ve opened Virtual Desktop on your PC.
Last, open your project from command prompt by using an injection method. You should type it in this structure:

  1. Locate your Virtual Desktop executable. Mine is at “D:\Virtual Desktop Streamer\VirtualDesktop.Streamer.exe”, your location may differ.
  2. You’ll need to locate your file path for the desired version of Unity. Mine is at “C:\Users\TStef\OneDrive\Documents\UnityProjects\2019.4.20f1\Editor\Unity.exe”.
  3. You’ll need the folder path of your project. My current project is located at “D:\UnityProjects\VRIT_V2”.

Note: If you encounter any errors, make sure there are no type-o’s and try removing the whitespaces from your folder and filenames.

Now that you know your file paths, you can type out the command like this:
“Virtual Desktop file location” “Unity editor file location” -projectpath “project folder path” useHub -hubIPC -cloudEnvironment production

For example, my project would be typed out like this:

“D:\Virtual Desktop Streamer\VirtualDesktop.Streamer.exe” “C:\Users\TStef\OneDrive\Documents\UnityProjects\2019.4.20f1\Editor\Unity.exe” -projectpath “D:\UnityProjects\VRIT_V2” useHub -hubIPC -cloudEnvironment production

You may not need “-useHub -hubIPC -cloudEnvironment production” in your command, but some people have reported that this cleared up some HMD detection issues.

Unity should now open with your VR project. Now turn your headset on, make sure it is not in sleep mode. Launch Virtual Desktop on the headset. Press Play in Unity, you should now be playing your scene wirelessly.

Note: If it doesn’t work the first time, you may need to click Stop, then click Play again to allow it to finish initializing.

--

--

Thomas Steffen

I am Virtual Reality Developer, UI Systems, and general programmer with a passion for Unity software development.