How to develop for Oculus Rift with Unity 3D in OS X (or yet, how to adapt your Unity 3D apps for Oculus)

September 25, 2015

Almost 25 years before “The surprising joy of virtual reality” (???), that’s what mainstream media used to say about Virtual Reality. What has changed since then? Hype or real?

Since May 15, 2015, the Oculus Rift team announced they decided to “pause” the support for OS X and Linux platforms. However, it is still possible to get the device running on OS X and develop new applications for it with Unity 3D (or yet adapt your Unity applications for Oculus).

Here’re the steps I’ve followed in order to get Oculus Rift (DK2) working with Unity 3D (tested in 5.2.0f3, not working, and in 5.1.1f, which works fine) in OS X (tested in 10.9.5). I assume you have basic knowledge about Unity 3D. In case you don’t have, make sure you explored its basics before trying continue reading this (some tutorials on Unity’s website might help).

Step 1 – Testing Rift

The goal here is to install Oculus Rift Runtime and test if it is working all right in your computer:

  1. Download the Oculus Rift Runtime for OS X available here;
  2. Plug the device in your computer. If you plugged everything right, the device should work as an external monitor;
  3. Make sure the resolution is set properly (in my case, for example, 1080p with Rotation of 90º). You might want to make sure you have updated the firmware of your device;Screen Shot 2015-09-25 at 10.39.03 AM
  4. Open “RiftConfigUtil”, which comes inside the Runtime package you downloaded in the substep 1. This is what you should see:Screen Shot 2015-09-25 at 10.42.55 AM
  5. Click in “Show Demo Scene” and wear the glasses. Wear the glasses and check if everything is working all right. That’s the example you should see:

Step 2 – Testing Rift & Unity

In case Rift does work in tour computer, now it’s time to install Unity 3D and its Oculus Fit Plug-in:

  1. Download a free version of Unity 3D available here. At first, I tried the most recent version (by the time I write this, the 5.2.0f3). Unfortunately, this version did not work for me, as explained here. With version 5.1.1f, however, everything worked fine (this is the one I’m using for this post);
  2. Download the Oculus Utilities for Unity 5 available here;
  3. Create a new project in Unity, and import the asset you downloaded in substep 2 (Assets -> Import Package -> Custom Package, then select the Oculus’ package. If everything works fine, you should see the following folders in your project tab:Screen Shot 2015-09-25 at 11.01.32 AM
  4. Go to the folder “Scenes” and open any of the examples available (I chose the “Cubes”);
  5. Go to Assets -> Project Settings -> Player -> Other Settings, and make sure the option “Virtual Reality Supported” is checked;
  6. Run! If everything is working all right, you should see this:

Step 3 – Taking control

Now, it’s time to have fun and create your own thing!

The asset you, imported has two Prefabs you can use in your custom Unity project. They are (description taken from the Oculus Unity Integration Guide):

  • OVRCameraRig: “OVRCameraRig replaces the regular Unity Camera within a scene. You can drag an OVRCameraRig into your scene and you will be able to start viewing the scene with the Gear VR and Rift”.
  • OVRPlayerController: “The OVRPlayerController is the easiest way to start navigating a virtual environment. It is basically an OVRCameraRig prefab attached to a simple character controller. It includes a physics capsule, a movement system, a simple menu system with stereo rendering of text fields, and a cross-hair component”.

In my case, I decided to use the scenario used for the project “29 de Abril” (downtown area of Curitiba, Brazil). All I needed to do was:

  1. At first, I tried to replace my “SimpleCharacterController” by the OVRPlayerController prefab, but it didn’t work for me (neither the mouse nor the keyboard was working). The way to go was to create a First Person Shooter, and then replace the “MainCamera” by the OVRCameraRig object (solution proposed here);
  2. Go to Assets -> Project Settings -> Player -> Other Settings, and make sure the option “Virtual Reality Supported” is checked;
  3. The last thing concerns skyboxes (if your example does no use Skyboxes, skip this step). Regular skyboxes do not seem to work with Oculus. Fortunately, I found this thread in which a user (thanks, Nora!) developed a script that allows us to overcome the issue. Just attach the script to your camera.

The result you can watch below:

That’s it! Let me know how it works for you!

Other useful resources here:

PS: November 2015 – I finally found some time to develop a functional prototype of the project “29 de Abril” for VR glasses (Oculus Rift). As you may notice below, the prototype still has several problems. The integration was not as easy as I had initially imagined.

Advertisements

One Response to “How to develop for Oculus Rift with Unity 3D in OS X (or yet, how to adapt your Unity 3D apps for Oculus)”


  1. […] aware that some people could make it work after similar workarounds but it simply did’t work for me and after […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: