So, you have a Samsung Gear VR, and you want to develop for it using Unity?
Great! Then this post is for you! I’ll show you how to get up and running with the minimum of fuss. Just follow the instructions below…
A few things before getting started…
I went through this setup procedure with a Gear VR (Innovator Edition) headset, paired with a Samsung Galaxy S6 phone. Don’t worry if you own another version of Gear VR (or Samsung Galaxy phone); the setup should be pretty much identical.
The instructions were written for a Windows PC (I’m using Windows 10). However, you should find that even if you are developing on a Mac, the process should be fairly similar.
I am assuming, however, that your phone is already set up to work with your Gear VR, and that you have installed and played (at least) a couple of the VR experiences available on ‘Oculus Home’ :
If haven’t set up your phone/Gear VR yet, you may find these YouTube videos helpful:
Samsung Gear VR Goggles for Galaxy S6 Unboxing & Setup – a quick visual run-through.
Gear VR – Setup, Tutorial, App Management – a very comprehensive, in-depth tutorial.
OK, Let’s go!
STAGE 1: Install the Java SDK on your PC.
First of all, you need to install the latest version of the Java SE Development kit on your PC.
In your web browser, go to: http://java.oracle.com
In the main header menu, mouse-over ‘Downloads’ , then click on the Java for Developers option (under ‘Popular Downloads’). You should now be on the Java SE Downloads page, click on the JDK ‘DOWNLOAD’ button.
You should now be on the Java SE Development Kit 8 Downloads page. Go to the sections relating to the latest version of the ‘Java SE Development Kit’, click the ‘Accept License Agreement’ radio button and then click on the correct jdk download link for your operating system ( I clicked the ‘jdk-8u112-windows-x64.exe’ link ).
Once the executable has downloaded, run it. The Java SE Development Kit installer will launch:
Important: Please make a note of the Installation folder for the Java SE Development Kit (or JDK). Unity will ask for the folder location, the first time you run a build.
Accept all the standard settings and install.
STAGE 2: Install the Android SDK on your PC.
Unity uses the Android SDK (Software Development Kit) in order to create a Gear VR build. The simplest way to install the SDK, is to install Android Studio. We will do this now…
In your web browser, go to: https://developer.android.com/studio/
Click on the ‘DOWNLOAD ANDROID STUDIO’ button.
Once the Installer has finished downloading, run it. The Android Studio Setup wizard should launch.
You can accept all the default settings. However, when you reach the Choose Install Location section, make sure you make a note of the ‘Destination Folder’ (Unity will need to know this during the build process).
STAGE 3: Configure your phone for app development.
With your phone on, and detached from your Gear VR headset, tap on the ‘Apps’ icon on the Home Screen.
Next, click on the ‘Settings’ icon. In the ‘Settings’ menu, scroll down until you find the ‘About device’ option and tap it.
On the ‘About device’ screen, scroll down until you can see the ‘Build number’ item. Now, tap on ‘Build number’ 7 times! This “secret” action will unlock ‘Developer options’ on your phone!
Go back to the main ‘Settings’ menu. You will notice that a new item, called ‘Developer options’, has appeared above ‘About device’. Tap on ‘Developer options’.
On the ‘Developer options’ screen, switch on ‘USB debugging’ (the switch should turn green). An ‘Allow USB debugging?’ prompt will appear, tap ‘OK’ to confirm.
Now, connect your phone to your PC via the phone’s USB cable.
Another prompt asking ‘Allow USB debugging?’ will appear. You will notice a checkbox with the text ‘Always allow from this computer’. It is important that you tick this box, and then tap ‘OK’.
STAGE 4: Create an Oculus Signature file.
In order for you to be able to play your Unity app on your Gear VR, you will need to include an Oculus Signature File (osig) in your project. Here’s how to create one …
On your phone, go to the Google Play Store and install a free App called: SideloadVR DeviceID
Now, launch the SideloadVR DeviceID App:
You will notice an alpha-numeric string under ‘Your Device ID is:’ . Make a note of this Device ID somewhere, you will need it shortly to generate your Oculus Signature File.
Now, back to your PC…
In your web browser, go to this page on the Oculus Developer website: https://developer.oculus.com/osig/
Note: You will need to be signed up and logged in as an Oculus Developer, in order to use the OSIG Generator on this page. If you have not yet signed up for an Oculus Developer account on this site, please do so now. Ensure that you are logged in.
On the OSIG Generator page, type your phone’s Device ID into the field provided (you should have noted this down in the previous step).
Click on the ‘Download File’ Button.
An Oculus Signature File (osig) will be generated and downloaded. It will be named: oculussig_[Device ID]
Save this file somewhere, where you can find it easily. You will need it later, to ‘sign’ your Unity/Gear VR projects.
STAGE 5: Install Unity 5.
In your web browser, go to the Unity website: https://unity3d.com/
From the menu at the top of the page, click ‘Get Unity’. You will be taken to a download page.
You have the option of downloading either the free or professional versions of Unity. The free version of Unity will allow you to develop for Gear VR, so unless your situation excludes you from the terms of the free license, you will probably want the ‘Free Download’ option (you can always upgrade to a pro license later). Click on the Download button.
On the next page, click the large ‘Download Installer’ button.
The Unity Download Assistant should now download. At the time of writing, this file is called ‘UnityDownloadAssistant-5.5.0f3.exe’. Run it now.
The Unity Download Assistant should now launch.
Click ‘Next >’, accept the Terms & Conditions…
You should reach a stage where you are prompted to ‘Choose Components’.
Make sure you tick ‘Android Build Support’ (it will be unchecked by default), then click ‘Next >’.
You should then be prompted to ‘Choose Download and Install locations’ (you can leave the defaults). Click ‘Next >’. The installation process should then begin.
Launch Unity 5. The First time you do this, you may be be presented with some Setup steps, prompting you to Sign in to a Unity account and/or to select a license (you’ll probably want the ‘Unity Personal Edition’ option!). Complete these steps.
STAGE 6: Create a Gear VR Project in Unity.
You should be presented with this project launch window:
With the ‘Projects’ tab selected, click on the ‘NEW’ button.
You will be asked to supply a ‘Project name’ and ‘Location’ for your new Unity project.
Fill in these fields, make sure the ‘3D’ option is selected, and click the ‘Create project’ button.
Your new project will be created and opened in the Unity 5 Editor.
NOTE: If this is your first time using Unity, I strongly suggest that you take some time to learn the basics of the interface and creating projects. A good place to start would be Unity’s own beginner tutorials, for example: https://unity3d.com/learn/tutorials/topics/interface-essentials
For those familiar with Unity, you will know that every Unity project contains an ‘Assets’ folder. The ‘Assets’ folder is where all your project’s assets (i.e. audio, graphics, scripts, scenes …) are created and saved. The ‘Assets’ folder (and it’s contents) exist within the project’s file structure, which is also reflected and accessible from the ‘Project’ panel in the Editor.
In order for your VR app to run on your Gear VR, you will need to add that Oculus Signature File (that you generated earlier), to your project.
Before you do this however, you will need to create a specific file structure within the ‘Assets’ folder.
Firstly, in the ‘Assets’ folder, create a sub-folder called ‘Plugins’. Next, within ‘Plugins’, create an ‘Android’ folder. Finally, within this ‘Android’ folder, create a folder called ‘assets’. Your ‘Assets’ folder structure should now be as follows:
Now you need to find that Oculus Signature File (osig) that you previously generated, and copy it into:
Reminder: The Oculus Signature File will be named like this: oculussig_[Device ID]
Your Unity project should now look something like this:
Now, lets give ourselves something to look at in VR…
From the top menu and select: GameObject → 3D Object → Capsule
Move the newly created ‘Capsule’ object in front of the ‘Main Camera’, so that it is clearly visible in Camera’s view.
This is all we are going to do as far as our scene goes, so let’s save it.
From the top menu, select: File → Save Scene
You can save the scene in the root ‘Assets’ folder, I saved it simply as ‘scene’ ( scene files have a .unity extension).
(This is probably a good point to save the entire project also.)
STAGE 7: Build and Run your Gear VR App.
Ok, it’s time to actually create a build. Make sure your Android phone it connected to your PC via it’s USB cable.
Firstly, from the top menu, select: Edit → Preferences…
The Unity Preferences Window should appear. From the sidebar, select the ‘External Tools’ option.
For Unity to be able to create a build, it needs to know the location of both the Android SDK and the Java JDK (you should have made a note of these previously). You will notice two text-fields under Android, enter the relevant paths there.
For reference, my paths are as follows:
(Android) SDK: C:\Users\milan\AppData\Local\Android\sdk
(Java) JDK: C:\Program Files\Java\jdk1.8.0_112\
Next, from the top menu, select: File → Build Settings…
The Build Settings Window should appear. From the Platform options, select ‘Android’, then click on the ‘Player settings…’ button.
The Inspector Panel should now be populated with Player Settings. On the Inspector Panel, ensure that the Android tab is selected.
Now, tick the ‘Virtual Reality Supported’ check-box.
You will need to supply a unique Bundle Identifier . I entered: com.mycompany.test
You must also select the a ‘Minimum API Level’ of at least 19. To be safe, let’s select the very latest API. At the time of writing this is:
Android 6.0 ‘Marshmallow’ (API level 23)
Go back to the Build Settings Window. Click on the ‘Add Open Scenes’ Button. This will add our current scene to the ‘Scenes In Build’ list.
Now, click the ‘Build an Run’ button.
You will be prompted to pick a location for your App build (I like to create a folder in the root of the project called ‘Bin’, as my Build location, but it’s up to you). You will also need to enter a file name for your App. I called mine ‘test’ (you will note that the extension for an Android App is .apk)
The build process should then commence…
Once the build is complete, a new App (called ‘Test Gear VR’) will be installed on your phone. An ‘Insert device’ prompt should also appear on your phone.
Insert your phone back into your Gear VR, your App should start automatically once you don the headset.
(If the ‘Insert device’ prompt is not showing, tap the ‘Test Gear VR’ App Icon)
After the brief Unity Splash screen, you should see the ‘Capsule’ scene in all its VR glory!