Setting up Unity for Gear VR development


Setting up Unity for Gear VR development is a relatively straightforward task, but working with VR makes it more complicated for new developers.

Although VR is officially supported with Unity 5.1, most of the “tutorials” or “guides” out there are pretty out of date. And since Oculus (what Gear VR runs on) keeps updating their Utilities for Unity quite often it so happens that every update brings new ways to setting up Gear VR.

In this tutorial, I’m going to be using Unity 5.4 although it also should work with 5.3 as well.This guide contains all the tips and procedures followed to get it working and hopefully this will get you up to speed for mobile VR development as well.

Setting up your Android Environment

This guide assumes that you have set up Java SDK and Android SDK and working USB drivers for your Samsung device on your machine. If not there are plenty of guides out there which will help you. This is Unity’s official guide.

Once you have that and you wish to test the apps on your Samsung device without docking your phone into Gear VR every time you build and run from Unity you can enable development mode for Gear VR.

  1. Go to Settings on your Samsung device.
  2. Open Application Manager > Gear VR Service and select that.
  3. Select Storage  > Manage Storage
  4. Click on VR service version several times until it says “You are a developer” and the Developer Mode toggle shows up.
  5. Toggle Developer Mode.

Setting up Unity for Gear VR

Again note that I’m using Unity 5.4.1f1.

The good thing with Unity 5 is you don’t need to do any additional integration for it to make it work with VR. All you need is the Oculus Utilities which include all the API, scripts and prefabs we need to work with Gear VR which is in the form of a unity package.Download it from here.(Under Engine Integration).

  1.  Open up Unity and create a new project.

screen-shot-2016-11-15-at-7-03-14-pm

  1. Since we’re building for Android, Go to File > Build Settings. Select Android and hit switch platform.

screen-shot-2016-11-15-at-7-13-05-pm

  1. In the same Build Settings open the Player Settings. Set Virtual Reality Supported in the Other settings which would show Oculus under SDK’s. Also set your Bundle Identifier and Minimum API Level while you’re at it.

screen-shot-2016-11-15-at-7-16-26-pm

  1. To run your Oculus app on the device, you will need a signature file(.osig) from Oculus. Register as a developer on Oculus and generate your .osig file from here:

You will need your Device ID for this which you can get by running adb devices on a terminal or a Command Prompt on Windows. Copy that into the form and download the .osig file. This file should be placed in the following directory inside your unity project – /YourProjectDirectory/Assets/Plugins/Android/assets/. If such DIR doesn’t exist, create one. If you don’t do this step you will see the APK is not Signed error while running the App.

  1.  Open the OculusUtilities.unitypackage you’ve downloaded which will open in Unity. Select all and Import. This contains all the Universal Scripts, Event Handlers and much more which all are needed to create a VR App. Although Unity has made integration with Gear VR much simpler and complete than before, it still lacks these utilities.

Once importing is done the OVR and Plugins Folder in your project will be there which contain all the said utilities we will be using later.

In the scenes Folder under OVR you can find a few example scenes which are basic at best.

You can download the VR Samples from Unity’s Asset store  which have more detailed projects built specifically for Gear VR and Rift.

screen-shot-2016-11-15-at-7-29-03-pm

screen-shot-2016-11-15-at-7-37-09-pm

  1. To test the demo scenes on your device connect it to your machine. Open the Scene and go to File > Build Settings or Shift + CMD + B on a mac and click on Add Open Scenes. Check the Scene(s) you want to be in your app. Then select Build & Run.

Insert your device into the Gear VR headset and test.

Comments are closed.

Send Lesson #1
Join 1000s of VR Developers

Build your Career in VR with this 6 part FREE course

Send Lesson #1
close-link
Add Me To VIP
Join 1000s of VR Developers

Build your Career in VR with this 6 part FREE course

Send Lesson #1
close-link
We've launched a WebVR Course with 25+ projects with source code! Check it out.
Get The Course
close-image