As soon as my Oculus Quest arrived, I immediately started playing with it and have fun with Beat Saber, Robo Recall, Creed and all the other titles. But then, as a developer, I felt the urge to understand how to develop my applications in Unity for the Oculus Quest. And I guess that if you are a developer like me, you had my some thought. That’s why I decided to create this little tutorial: to help all the Unity developers that want to get started in developing for the latest Oculus standalone device in understanding what are the first steps to follow.
If you have already developed for other Oculus devices like Go or Rift, the good news is that the process is mostly the same. The reason is that Oculus uses the same plugin to handle all its devices, and that’s a good thing for developing cross-platform titles. And there’s even more: the structure of the plugin is remaining constant over time… I can say that there are some things that have not even changed from the Oculus DK2 times! So, even if you are not developing for Oculus devices since a lot, you will need very little time to understand the basics of Quest development.
Video Tutorial: How to get started with Oculus Quest development in Unity
I prepared for you a tutorial that covers the basics on how to get started, that is:
- How you can download Unity
- How to unlock developer mode on the Quest
- Where you can find the Oculus Quest plugin for Unity
- What is the structure of Oculus plugin
- How to create your first simple scene for VR
- How to build your Unity project and deploy it on the Quest
- How to find your application inside Oculus Quest UI
UPDATE: I actually forgot to include in the video the part where you install the Android dev tools, that you can find at the point 2 of the textual tutorial here below.
And for the first time, I decided to make it in a video version, since I know that most people like watching video-tutorials! Forgive me if the video is a bit rough, but it is my first one… and then I made it yesterday evening when I was really tired. I hope you’ll also like my Italian accent 😉
Textual Tutorial: How to get started with Oculus Quest development in Unity
If you, like me, like more textual guides, because you can skim them faster, let me provide you also a textual version of the main points highlighted in the video. In the video, I provide you more details and I go more step-by-step, but using this textual guide, you should get the job done the same 🙂
1. Unlock developer mode on your Quest
The first thing to do is unlocking the developer mode on your Quest. To do this, you should:
- Turn on your Quest;
- Run the Oculus app on your smartphone;
- In the Oculus app, select Settings in the lower right corner;
- Tap on the button corresponding to your Oculus Quest to perform the pairing;
- In the contextual menu that pops up select “Other settings”
- In the new settings window that comes to your screen, select Developer Mode;
- Click on the slider to activate the developer mode;
- Yay! You are now officially a developer!
2. Install Android Tools
In the first version of this article, I forgot an important part of the environment set-up: installing Android development tools (thanks 이상일 for reminding me this)! If you are not an Android developer, you have to install Android Studio, with the related Android SDK and Android SDK Tools, so that your PC becomes ready for Android development.
I won’t go too much into details about that here, because it would require a separate guide only for that. Anyway, the most important thing to do is installing Android Studio downloading it from its website. After that, you must use its IDE to install the required Android SDK. Open Android Studio and select Tools->Android -> SDK Manager to open the SDK Manager. Inside it, you can install the required SDKs for Android development.
I suggest installing Android 4.4 (SDK 19) and Android 7.1 (SDK 25). Install also the various SDK Tools and Platform Tools. After that, put the directory <Android_sdk_install_dir>\platform-tools inside the PATH environment variable, because this may help you in the future if you want to use ADB (e.g. to record videos). If you have installed Android Studio without specifying custom directories, <Android _sdk_install_dir> may be found in “C:\Users\<username>\appdata\local\android\sdk” in Windows PCs.
If you want some help for all this process, have a read to this tutorial.
UPDATE: As Ivan Berg makes me notice in the comments, you can install Android Tools during Unity installation process, while you select the Android Build Support.
3. Install and run Unity
If you have not installed Unity, yet, get it directly on Unity website. If you are experimenting on your own, select that you want to try the personal edition, that you can use for free forever until you (or your company) make more than 100K every year.
Personally, I’m still using Unity 2018.3.6f1, because it is the one that I’m using for other projects what I’m developing for my consultancy company (contact us if you need an AR/VR solution!), but actually Oculus advises to have one of these 3 versions:
- 2017.4 LTS
- 2018.4 LTS
- 2019.1.2f1
And in general, to have a version above the 2017.4.11f1. If your Unity version is not one of three ones specified above, some problems may arise (I’ve read for instance that there are some known issues with Unity 2018.2). Personally, I have had no problems with the version that I’m using.
When installing Unity make sure that you install the Android Build Support.
Once you have installed Unity, launch it.
4. Create a new project
At Unity startup, select that you want to create a new project (there is a button in the upper right part of the window) and call it as you wish, for instance “OculusQuestTest”. It must be a 3D project (it should be the default option already).
As the folder, pick the one that you prefer on your drive. Keep in mind that Unity will create in this folder a subfolder with the name of the project that will contain all the elements of the project itself.
When you’re ready, hit “Create Project”.
At this point, Unity will show you its typical interface, with your blank project opened.
5. Import Oculus Plugin
Oculus has made things easier for developers recently: you can download the Oculus Plugin directly from inside Unity. The steps to do this are:
- In the Unity menu select Window -> Asset Store;
- In the Asset Store window that will pop up, write “Oculus Integration” in the search box that is in the upper part of the layout;
- Click on the first result (a plugin made by Oculus, that is free);
- In the corresponding details page, hit the Download (or Update, if you had already downloaded it) button. Play with your cat while the system downloads the plugin;
- Once the download has finished, the button will become “Import”. Click on it again;
- In the upcoming window, select “Import”. Play again with your cat while Unity imports and compiles all the resources;
- If after that you see a dialog window asking you if you want to update the Oculus Plugin Utilities, select “Yes”. Select “Restart” in the next window;
- Unity will re-start itself. Time to play with your cat again!
Cool, now you are ready to develop for Oculus devices!
6. Create your first VR scene
We will now create an amazing VR experience with a cube in front of you. I know… it’s your dream app… so, let’s make it!
- In the Hierarchy window in Unity’s interface, click on “Main Camera”. Then click “Canc” on your keyboard to remove it from the scene. We are removing the standard camera, to add a VR camera;
- In the Project window, navigate to Assets\Oculus\VR\Prefab;
- Drag the OVRCameraRig prefab into the Hierarchy window. This will make sure that we will have a VR camera that will represent our player’s head;
- In the Hierarchy Window, click on the little Create button and select 3D Object -> Cube. A cube will appear in your scene;
- With the cube selected in the Hierarchy Window, look at the Inspector window on the right. In the Transform behaviour, set the Position: Z value to 2 to move the cube in front of the head of the user;
- Save the scene using the menu File -> Save
Cool, we have just made our VR cube scene!
7. Set build settings
Let’s configure the build of your project!
- In the menu select File -> Build Settings…;
- In the build settings window, in the Scenes In Build upper part, select the “Deleted” entry, if any, and hit Canc on your keyboard to remove it;
- Click the Add Open Scenes button to add your just created amazing cube scene to the build of your project;
- In the Platform tab, select Android and then hit Switch Platform. This will take a while, so give some food to your cat;
- When Unity will have finished, click on the “Player Settings…” button in the lower left corner of the window. This will open the Player Settings in the Inspector of the main Unity window (so on the right);
- Change the Company Name and the Product Name as you wish in the upper part of the Player Settings.
- Scroll down and unfold the “Other Settings” section;
- In the Identification part, change the Package Name so that it is coherent with your organization (e.g. call it com.yourcompanyname.OculusQuestTest);
- Always in the Identification part, change the Minimum API Level to 4.4 KitKat;
- Scroll down and unfold the “XR Settings” section;
- Check that Virtual Reality Supported is checked;
- In the Virtual Reality SDKs part, click on the little “+” button and select “Oculus”.
The project is now ready to build!
8. Build and run!
We are finally so close to run our game!
- Connect your Quest to your PC via an USB cable;
- Put the Quest on your head and if the system asks you if you want to enable USB debugging for this PC, select to remember the choice and then select Yes;
- Go back to Unity and in the Build Settings window click on the “Build and Run” button in the lower right corner;
- Choose a name for your APK and select where you do want to put it (it is not important for the final result);
- Wait for the system to build your game and deploy it to your device. Your cat will help you in spending your time;
- When the build has finished, put the Quest on and enjoy your cube!
- After that, let your cat enjoy it as well.
Congratulations! You have made your first application for the Oculus Quest!
UPDATE: A little group of readers reported that the app created this way crashed on start. In this case, try the solution suggested by Ivan Berg in the comments: select Project Settings -> Player -> Other Settings -> Graphics APIs -> (Remove Vulcan)
9. Future possibilities
To continue learning development, have a look at the sample scenes that are located in Assets\Oculus\VR\Scenes and in Assets\Oculus\SampleFramework\Usage. You will learn a lot from them.
You can also read the official documentation of Oculus Quest development in Unity that you can find at this link.
Or just enjoy this cat vs cucumbers video
This tutorial is over and I hope that it has been useful for you to get started with Oculus Quest development in Unity. If it is the case, please share it with your peers, and let me know in the comments or on my social media channels if you want me to make other Quest dev tutorials (and what you would like to see).
Consider also making a donation to my Patreon to support my creation of free resources for the VR community!
Have fun with Oculus Quest development 😉