Unity Settings for a Seamless VR Experience

Math.CS
Developer Community SASTRA
5 min readJan 4, 2024

Unity is a Game Engine developed by Unity Technologies to work across platforms ranging from Desktops and Phones to even VR in the recent past. In Unity, there are some choices that are presented to us when we create new projects like 2D,3D, AR Core, etc. Most of the time, the project doesn’t change too much in the development process in terms of the settings it requires to function as required. But, when it comes to VR (Virtual Reality) in Unity, it is very important to make changes from the default settings for it to work properly. In this article, we will set up Unity for VR step-by-step and understand the reasoning for each step along the way.

But before we get into the technicalities, this article is written with Unity 2022.3.2f1 as a reference and the VR device referred to in this post is Oculus Quest 2. There might be some minor changes if you are using a different version than the one mentioned here, but the settings are mostly the same. Let’s get started then.

  1. Create a new 3D Core project. Since VR is usually associated with a multi-dimensional viewing experience, a 3D core is used.
  2. Go to Edit >> Project Settings and click on XR Plugin Management. Click on Install XR Plugin Management. This might take some time depending on your system. XR Plugin Management is the package that provides a simple way to manage XR plugins from loading and initialization to build support for XR.
  3. Now this window will be visible, if the installation is successful.

Click on the computer symbol highlighted in red in the above image and check Oculus. Similarly, click on the tab with the Android symbol and check Oculus there too. Once this is done, close the window.
Here, we have selected Oculus as the plugin provider for Android because the Oculus device is powered by the Android OS and we want the project to work in that device.

4. Now, go to Window >> Package Manager, and in the drop-down menu next to the plus symbol in the top left corner, click on Packages: Unity Registry. In the packages section, scroll down to find the XR Interaction Toolkit. In the pane on the right side, click on install.

A popup will appear asking if Unity can be restarted. Make sure to give Yes. Then, a popup titled “XR InteractionLayerMask Update Required” appears. Click on I Made a Backup, Go Ahead.
XR Interaction Toolkit(XRI) is responsible for handling and managing how we interact in VR. For example, how clicking a button in the controller is transformed into functionality is all handled by XRI.

5. After Unity Editor restarts again,head over to the XR Interaction Toolkit in the Package Manager. Now, click on the tab named Samples,which will be visible in the right pane.

Under Starter Assets, click on Import. Once it’s done, close the window. In the project, you would be able to find the package we just imported in Assets >> Samples >> XR Interaction Toolkit >> 2.3.2(Any version number).
The Starter Assets package is very important, as it contains default Input Action and Input Bindings, that contain presets for movement, turning, etc.

6. This is what the Starter Assets package looks like.

Now, click on any file that has this icon given below.

A pane similar to this will be visible in your in the Inspector tab.

Now, click on the button highlighted in the image above. Perform the above step for all the files that have this icon.
Why are we doing this? Well, before this step, we had a preset that contained various functionalities,but we have to tell Unity to refer to it as its default behaviour. Clicking on Add to ActionBased essentially does that.

7. This is one of the most important steps in this process. Head over to Edit >> Project Settings >> Preset Manager and make changes as given in the image below.

There is some preset that is present by default for the controllers. But, we need to manually assign the particular preset for each controller. That is why we assign the values Right and Left for the controllers. Gaze is predominantly used for providing the users with more realism while interacting in VR through eye-tracking, head-tracking, and other features in newer headsets Meta Quest Pro and HoloLens 2.
Note: Some versions of Unity might not have the option of Gaze. In that case, just fill up the values for Right and Left. Close the window.

8. This is the last and final step. You would have noticed that the Hierarchy Window still has the Main Camera in it. Delete it and add XR Origin(VR) in its place. For that, click on the ‘+’ symbol in the top left corner of the hierarchy window and go to XR >> XR Origin(VR). Doing this would have added two new things to your hierarchy window: XR Origin and XR Interaction Manager.
XR Origin is very important as it contains the Main Camera and the Right and Left Controllers. Just like how the main camera is like the eyes for a 2D or 3D game, the XR origin plays a similar role in XR.
The XR Interaction Manager is basically like the interface between the interactors and interactables. Most of the methods are called through the interaction manager ensuring integrity on both ends.

Once you have completed the above steps successfully, you can start developing your project and experience it on your VR device.

--

--

Math.CS
Developer Community SASTRA

Dive into the world of Mathematics, Computer Science, Emerging Technologies and much more. A place where fun meets learning.