How to setup a fast development workflow (plug and play) for Oculus Quest 2 with Unity

2.4k Views Asked by At

How would I go about setting up Unity and Oculus so I can hit Play in Unity and see the results immediately instead of building and running the game on Oculus?

1

There are 1 best solutions below

0
On

First off, these are the essentials one needs in order to develop for Oculus Quest 2 with Unity. After completing these steps, you can, if you want, do the other ones to have the fastest possible workflow.

Unity side:

  1. Install Unity (anything above 2018 would work, preferably the latest). Check the Android Build Support module, as well as the Android SDK & NDK and OpenJDK checkboxes.
  2. Open a new 3d empty project. (preferably open it for the Android platform)
  3. In Build Settings, switch to Android platform. (if it's not already)
  4. In the Package Manager, install the XR Plugin Management and the Oculus XR Plugin
  5. In Project Settings -> XR Plugin Management, go the Android tab and check the Oculus option. Wait for the import to finish.

For the Oculus side:

  1. Make an Oculus Developer account
  2. Put on your Quest 2 headset and log in to your developer account.
  3. In your Quest 2 headset, go to Settings -> System -> Developer and turn on the USB Connection Dialog option. Alternatively, you can do the same with the Oculus Android app. Do one or the other.
  4. Connect the headset to the pc/laptop with a usb-c to usb cable (like the Oculus Link cable, but it will work with third-party cables as well) and accept all the dialogues that show up, namely the "Allow USB Debugging", "Always allow from this computer", and the "Allow access to data".

Finaly, In Unity in Build Settings -> Run Device choose the connected Oculus device from the options and click Build & Run (make sure you have at least one scene added to Build Settings). This will build the application and push it to your Oculus (if connected via usb). When you put your headset on you will see the application load.

That's it. This is the bare minimum you need in order for you to develop VR games for Oculus. But of course if we leave it at that it's going to be really slow and tedious developing VR apps because we will have to code basic VR principles by ourselves and waste time on building and pushing the app to the device every time we want to change and test something. And so, we are going to install a few more things in order to speed up development.

  1. Install the Oculus Developer HUB. This will allow you to check if your device is connected to the PC properly, and also has other functionalities (you can screen capture and record video directly from the devices). Once installed, connect your device with a usb-c to usb cable and make sure it shows properly in the Oculus Developer HUB. (this step is NOT a must but I recommend it)
  2. Install the Oculus App for Quest 2. You can find it on Oculus website. We need this in order for the Oculus Link feature to work, which will allow us to test in real time instead of building and running the app on the Oculus.
  3. Run the Oculus App, and when you do it will show a setup guide. Follow the guide. You can choose connection via cable (cable link) or via wifi (AirLink).
  4. In your connected Oculus headset, a dialogue will pop up asking you if you wish to enable Oculus Link. Accept it.
  5. In Unity, go to Package Manager and install the XR Interaction Toolkit. This plugin greatly lessens the troubles of setting up a VR rig.
  6. In a new scene right click in the Hierarchy, go to XR -> Device-based -> XR Rig (could also say XR Origin)
  7. Click Play in Unity and put on your headset. You should see the tracking of the headset and controllers mirror in the Unity editor.

That's pretty much it for the development side. If you wish to build for Oculus, you just have to go to Build Settings and in the Run Device option choose the connected Oculus Quest 2 device and click Build and Run. And of course save the scene with the XR Rig and add it to Build Settings.

Tested to work with Unity 2020.3.25f1 on ASUS TUF laptop.

Feel free to correct me on some of the steps if you hit an obstacle. Would love to have as comprehensive guide as possible.