So you’re interested in VR development with the Samsung Gear VR. Fortunately, it’s not too difficult to get a build up and running on the Gear VR with Unity. It can, however, be an exercise in patience to figure out the steps to get started. I did some UI development work at Oculus and got accustomed with some of the hoops you need to jump through. I decided to write this guide as an attempt to clarify some of the details.
Please don’t take this guide as the absolute truth. The tools are constantly changing so some stuff may have been correct at some point but wrong at the present. Also, in the future, some things will definitely change. This is only intended as a starting point, a primer. If anything’s wrong, please let me know. There’s a lot to learn!
Here’s a quick rundown of the hardware that you may need and what role they play in development.
Samsung Gear VR
The Samsung Gear VR consumer edition
You probably already know this by now, but the Gear VR is a VR headset in which you plug a specific Samsung phone into and it becomes a standalone VR device. With hardware manufactured by Samsung, and software by Oculus, it was first introduced Fall of 2014 and a few models have been released since then.
There are 3 versions of the Gear VR:
- First Innovator Edition: Compatible with the Samsung Note 4 phone.
- Second Innovator Edition: Compatible with the Samsung Galaxy S6 and S6 Edge phones.
- Gear VR Consumer Edition: Compatible with the Samsung Note 5, the S6, the S6 edge and the S6 edge+ phones.
The consumer edition is what’s currently available in stores like Best Buy and Amazon right now. You may be able to pick up the older versions on the cheap on eBay or whatever.
Gear VR offers an experience way beyond that of something like Google Cardboard because the Gear VR has dedicated sensors for making head-tracking more accurate and custom software. This helps to ensure a smooth framerate and high fidelity experience.
Click here for more information on the Gear VR.
It’s not absolutely necessary, but it’s incredibly helpful to have an Oculus DK2 for development. During development, you’ll be able to preview your application’s functionality in VR directly from Unity. This is a huge time-saver. Otherwise you’ll need to build to the device every time you change something to get a feel for how it looks in VR.
I’m currently using a Microsoft Surface 3 with Intel integrated graphics that doesn’t work very will with the DK2. During the development of Raybeem, I just used a mouselook script on my camera to test the scene during development. It worked well enough to get by since the interaction in Raybeem is really minimal. I wouldn’t recommend it, but it’s possible to get by without it!
Nvidia/ATI Graphics card with 2-3 HDMI outs (preferable).
If you’re planning on using a DK2, as you should, you’ll need to have a decent graphics card. Preferably more than decent. Oculus recommends a NVIDIA GTX 970 / AMD 290 card for gaming on the Rift, you’d probly want something similar for development as well.
As I mentioned before, I think you’re out of luck if you don’t have an ATI or Nvidia graphics card in your machine. At the very least, I had no luck with my Surface 3. Don’t be crazy like me and come prepared! 😉
All you need is a video out for your monitor (DVI or HDMI I figure) and an HDMI-out for the DK2 headset.
Keep in mind though, if you’re building for Gear VR. It doesn’t matter how underpowered your development hardware is in the end, as long as it runs well on the device.
Moga Pro controller
It’s a good idea to have some sort of Bluetooth controller. I personally use the Moga Pro Power controller. Oculus also says that the Steelseries Android controllers work, but I figure any Bluetooth controller with twin-sticks and a proper HID controller implementation should work fine.
Installing the Runtime
Oculus Config Utility, installed with the runtime.
To use the DK2 on your computer, you’ll need to install the Oculus runtime. The runtime is basically the drivers that you need for your computer to recognize the hardware and run Oculus VR apps.
You can get the latest runtime and other downloads at: https://developer.oculus.com/downloads/
Get Unity 5
Lucky for you, Unity 5 now has VR support built in. Even the free version of Unity! Pretty sweet, don’t you think?
Get Unity 5 at http://unity3d.com/
Get Android SDK
You’ll need the Android SDK for any Android development. Gear VR is still Android development, ok? You can download the SDK at: http://developer.android.com/sdk/index.html. Ignore the Android Studio stuff, you just need the SDK tools. Make note of the folder you install the Android SDK to. You’ll have to point Unity to the folder, and you’ll need to use the command line to run adb commands from time to time.
After installing the SDK, make sure you have an appropriate SDK version installed. The minimum you’ll need is Android 4.4 ‘Kit Kat’ (API level 19). ‘Kit Kat’ is the default OS for Note 4 phones. Run the SDK Manager to pick and choose which SDK components you want installed. Just get what you think you’ll need because all of the components can take up a lot of HD space.
Gear VR dev
To run a VR enabled app on the Gear VR, you’ll first need to sign your Unity application. This is similar to iOS development but a way more straightforward process.
To sign Gear VR apps, all you need is an OSIG file. You get this by getting your phone’s serial number or IMEI and submitting it to a form on the Oculus developers website. There are full instructions on how to get your OSIG on that page.
Enter your serial number or IMEI on the Oculus developers site to get your OSIG file.
After getting your OSIG file, you must place it in a particular folder in your Unity project. The folder is:
You can rename the OSIG file to anything you want. You’ll need an OSIG for each device you plan on testing with and you can place as many OSIGs as you’d like in the folder. I usually rename the OSIG to tell which device it’s tied to.
Setup Unity Project
Enable Virtual Reality under Project Settings in Unity.
The Gear VR support is built in so all you need to do is enable VR support from within Unity 5. With this enabled, standard Unity cameras will function as VR cameras when running on a VR device. It’s pretty brilliant.
I found some recommended settings in a PDF Oculus used to bundle in the mobile SDK. These settings may exist in a more recent doc, but I haven’t come across them. This is a good starting point for Gear VR dev though.
I think these settings are all right aside from the Device filter supporting x86. It’s probably best to go with just ARM since all the supported devices are ARM.
For additional integration with the Oculus store and other functionality, there is also the Oculus Utilities for Unity 5 package that you can download from the Oculus developer downloads page.
If for some reason you’re still on Unity 4, you’ll have to use the Oculus prefabs from the Unity 4.x Legacy Integration package on the Oculus downloads page.
VR Development in Unity
An example of one of my VR test scenes.
While in Unity, you can use your DK2 to get a preview of how your scene looks in VR. Hitting play on the scene will beam the view directly to the VR headset. I typically layout a test scene with a checkerboard ground and box primitives to get a sense of scale when starting development.
If you don’t have a VR headset handy, a mouselook script on the camera is a poorman’s solution for testing within the editor.
Build to Gear VR
This what you came here for, right? If you’ve setup the project properly, all you need to do is build to the phone in Unity’s Android platform mode and you’ll be good to go. When the “Insert Device” screen comes up, pop the Gear VR in the phone and check out your creation.
If you get messages about the application suddenly quitting, 9 times out of 10 it’s an OSIG/signing related issue. See if you can get a simple scene with a few boxes or a checkerboard floor running to rule out other conflicts you might have.
Build to PC
There’s no trick to running VR builds on PC. Just switch the Unity platform to PC and you should be good to go! As long as the DK2 is connected and the proper runtime is going, a PC build will just work.
That’s it for Today!
This is a quick overview of how to get started with Gear VR development. If there are any questions or suggestions for things I left out, please let me know.
Here are some links that may be handy during your journey.
- Oculus Forum : Bustling community of Oculus enthusiasts.
- Unity 5 Manual – VR Overview : Some details on how Unity’s VR camera works.
- Unity VR Forum : The official Unity forum
- Oculus on Reddit
- Gear VR on Reddit