<html>
<p><img src="http://milanprucha.com/steemit/002-gearvr/00-gear-vr-unity.png"/></p>
<p>So, you have a Samsung Gear VR, and you want to develop for it using Unity?</p>
<p>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…</p>
<p><br></p>
<p> </p>
<h1>A few things before getting started…</h1>
<p>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’ : </p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/01-oculus-home-1.png"/></p>
<p>If haven’t set up your phone/Gear VR yet, you may find these YouTube videos helpful:<br>
<a href="https://www.youtube.com/watch?v=kDjHqXwn46A" target="_blank">Samsung Gear VR Goggles for Galaxy S6 Unboxing & Setup</a> – a quick visual run-through.<br>
<a href="https://www.youtube.com/watch?v=T_z5sLijIPg" target="_blank">Gear VR – Setup, Tutorial, App Management</a> – a very comprehensive, in-depth tutorial.</p>
<p><br></p>
<h1>OK, Let’s go!</h1>
<h3>STAGE 1: Install the Java SDK on your PC.</h3>
<p>First of all, you need to install the latest version of the <strong>Java SE Development kit</strong> on your PC. In your web browser, go to: <a href="http://java.oracle.com/" target="_blank">http://java.oracle.com</a><br>
In the main header menu, mouse-over ‘Downloads’ , then click on the <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html" target="_blank">Java for Developers</a> option (under ‘Popular Downloads’). You should now be on the <strong>Java SE Downloads</strong> page, click on the JDK ‘DOWNLOAD’ button.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/02-java-web.png"/></p>
<p><br></p>
<p>You should now be on the <strong>Java SE Development Kit 8 Downloads</strong> 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 ).</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/03-java-web-download.png"/></p>
<p>Once the executable has downloaded, run it. The <strong>Java SE Development Kit</strong> installer will launch:</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/04-java-sdk-install.png"/></p>
<p><strong>Important:</strong> Please make a note of the Installation folder for the <strong>Java SE Development Kit</strong> (or <strong>JDK</strong>). Unity will need the folder location, the first time you run a build.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/05-jdk-path.png"/></p>
<p>Accept all the standard settings and install.</p>
<p><br></p>
<p> </p>
<h3>STAGE 2: Install the Android SDK on your PC.</h3>
<p>Unity uses the <strong>Android SDK</strong> (Software Development Kit) in order to create a Gear VR build. The simplest way to install the SDK, is to install <strong>Android Studio</strong>. We will do this now… </p>
<p>In your web browser, go to: <a href="https://developer.android.com/studio/" target="_blank">https://developer.android.com/studio/</a><br>
Click on the ‘DOWNLOAD ANDROID STUDIO’ button.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/06-android-sdk-download.png"/></p>
<p>On the next page, tick the check-box to accept the terms and conditions, and then click the ‘Download Installer…’ button. Once the Installer has finished downloading, run it.</p>
<p>The<strong> Android Studio Setup</strong> wizard should launch.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/07-android-studio-setup.png"/></p>
<p>You can accept all the default settings. However, when you reach the <strong>Choose Install Location</strong> section, make sure you make a note of the ‘Destination Folder’ (Unity will need to know this during the build process).</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/08-configuration-settings.png"/></p>
<p> </p>
<h3>STAGE 3: Configure your phone for app development.</h3>
<p>With your phone on, and detached from your Gear VR headset, tap on the ‘Apps’ icon on the Home Screen.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/09-phone-on-s.jpg"/></p>
<p>Next, click on the ‘Settings’ icon. In the ‘Settings’ menu, scroll down until you find the ‘About device’ option and tap it.<br>
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!</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/10-phone-touch-build.png"/></p>
<p>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’.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/11-enable-usb-debugging.png"/></p>
<p>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.</p>
<p>Now, connect your phone to your PC via the phone’s USB cable.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/12-phone-connected.jpg"/></p>
<p>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’.</p>
<p><br></p>
<p> </p>
<h3>STAGE 4: Create an Oculus Signature file.</h3>
<p>In order for you to be able to play your Unity app on your Gear VR, you will need to include an <strong>Oculus Signature File</strong> (osig) in your project. Here’s how to create one … On your phone, go to the Google <strong>Play Store</strong> and install a free App called: <strong>SideloadVR DeviceID</strong></p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/13-sideload-install.png"/></p>
<p>Now, launch the <strong>SideloadVR DeviceID</strong> App:</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/14-device-id.png"/></p>
<p>You will notice an alpha-numeric string under ‘Your Device ID is:’ . Make a note of this <strong>Device ID</strong> somewhere, you will need it shortly to generate your <strong>Oculus Signature File</strong>. </p>
<p><br></p>
<p>Now, back to your PC… </p>
<p>In your web browser, go to this page on the Oculus Developer website:<br>
<a href="https://developer.oculus.com/osig/" target="_blank">https://developer.oculus.com/osig/</a> </p>
<p>Note: You will need to be signed up and logged in as an Oculus Developer, in order to use the <strong>OSIG Generator</strong> 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 <strong>OSIG Generator</strong> page, type your phone’s <strong>Device ID</strong> into the field provided (you should have noted this down in the previous step). </p>
<p>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).</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/15-oculus-sig-download.png"/></p>
<p>Click on the ‘Download File’ Button. </p>
<p>An<strong> Oculus Signature File</strong> (osig) will be generated and downloaded. It will be named:<br>
<strong>oculussig_[Device ID]</strong></p>
<p>Save this file somewhere, where you can find it easily. You will need it later, to ‘sign’ your Unity/Gear VR projects.</p>
<p><br></p>
<p> </p>
<h3>STAGE 5: Install Unity 5.</h3>
<p>In your web browser, go to the Unity website: <a href="https://unity3d.com/" target="_blank">https://unity3d.com/</a> </p>
<p>From the menu at the top of the page, click ‘Get Unity’. You will be taken to a download page.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/16-unity-5-download.png"/></p>
<p>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.</p>
<p><br></p>
<p>On the next page, click the large ‘Download Installer’ button.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/17-download-installer.png"/></p>
<p>The <strong>Unity Download Assistant</strong> should now download. At the time of writing, this file is called ‘UnityDownloadAssistant-5.5.0f3.exe’. Run it now.</p>
<p>The Unity Download Assistant should now launch.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/18-unity-install.png"/></p>
<p>Click ‘Next >’, accept the Terms & Conditions…</p>
<p><br></p>
<p>You should reach a stage where you are prompted to ‘Choose Components’.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/19-unity-components.png"/></p>
<p>Make sure you tick ‘Android Build Support’ (it will be unchecked by default), then click ‘Next >’.</p>
<p><br></p>
<p>You should then be prompted to ‘Choose Download and Install locations’ (you can leave the defaults). Click ‘Next >’. The installation process should then begin.</p>
<p>Launch <strong>Unity 5</strong>. 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.</p>
<p><br></p>
<p> </p>
<h3>STAGE 6: Create a Gear VR Project in Unity.</h3>
<p>You should be presented with this project launch window:</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/21-new-project.png"/></p>
<p>With the ‘Projects’ tab selected, click on the ‘NEW’ button.</p>
<p><br></p>
<p>You will be asked to supply a ‘Project name’ and ‘Location’ for your new Unity project.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/22-new-gear-vr-project.png"/></p>
<p>Fill in these fields, make sure the ‘3D’ option is selected, and click the ‘Create project’ button. </p>
<p>Your new project will be created and opened in the <strong>Unity 5</strong> Editor.</p>
<p>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:<br>
<a href="https://unity3d.com/learn/tutorials/topics/interface-essentials" target="_blank">https://unity3d.com/learn/tutorials/topics/interface-essentials</a> </p>
<p>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 <em>assets</em> (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.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/23-unity-editor-1.png"/></p>
<p>In order for your VR app to run on your Gear VR, you will need to add that <strong>Oculus Signature File</strong> (that you generated earlier), to your project. </p>
<p>Before you do this however, you will need to create a specific file structure within the ‘Assets’ folder. </p>
<p>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:</p>
<p><strong>Assets\Plugins\Android\assets</strong></p>
<p>Now you need to find that <strong>Oculus Signature File</strong> (osig) that you previously generated, and copy it into:<br>
<strong>Assets\Plugins\Android\assets</strong></p>
<p>Reminder: The <strong>Oculus Signature File</strong> will be named like this: <strong>oculussig_[Device ID]</strong></p>
<p>Your Unity project should now look something like this:</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/27-unity-osig.png"/></p>
<p><br></p>
<p>Now, lets give ourselves something to look at in VR… </p>
<p>From the top menu and select:<strong> GameObject → 3D Object → Capsule</strong></p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/25-unity-capsule.png"/></p>
<p>Move the newly created ‘Capsule’ object in front of the ‘Main Camera’, so that it is clearly visible in Camera’s view.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/26-unity-capsule-move.png"/></p>
<p>This is all we are going to do as far as our <strong>scene</strong> goes, so let’s save it. </p>
<p>From the top menu, select: <strong>File → Save Scene</strong></p>
<p>You can save the <strong>scene</strong> in the root ‘Assets’ folder, I saved it simply as ‘scene’ ( scene files have a <strong>.unity</strong> extension).<br>
(This is probably a good point to save the entire project also.)</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/24-unity-scene.png"/></p>
<p><br></p>
<p><br></p>
<h3>STAGE 7: Build and Run your Gear VR App.</h3>
<p>Ok, it’s time to actually create a build. Make sure your Android phone it connected to your PC via it’s USB cable. </p>
<p>Firstly, from the top menu, select: <strong>Edit → Preferences…</strong></p>
<p>The <strong>Unity Preferences</strong> Window should appear. From the sidebar, select the ‘External Tools’ option.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/28-unity-preferences.png"/></p>
<p>For Unity to be able to create a build, it needs to know the location of both the Android <strong>SDK</strong> and the Java <strong>JDK</strong> (you should have made a note of these previously). You will notice two text-fields under <strong>Android</strong>, enter the relevant paths there. </p>
<p>For reference, my paths are as follows:<br>
(Android) SDK: <strong>C:\Users\milan\AppData\Local\Android\sdk</strong><br>
(Java) JDK: <strong>C:\Program Files\Java\jdk1.8.0_112\</strong></p>
<p><br></p>
<p>Next, from the top menu, select: <strong>File → Build Settings…</strong></p>
<p>The <strong>Build Settings</strong> Window should appear. From the <strong>Platform</strong> options, select ‘Android’, then click on the ‘Player settings…’ button.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/29-unity-build-settings.png"/></p>
<p><br></p>
<p>The <strong>Inspector Panel</strong> should now be populated with <strong>Player Settings</strong>. On the <strong>Inspector Panel</strong>, ensure that the <strong>Android</strong> tab is selected.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/30-unity-playersettings.png"/></p>
<p>Now, tick the ‘Virtual Reality Supported’ check-box. </p>
<p>You will need to supply a unique <a href="http://docs.unity3d.com/ScriptReference/PlayerSettings-bundleIdentifier.html">Bundle Identifier</a> . I entered: <strong>com.mycompany.test</strong></p>
<p>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:<br>
<strong>Android 6.0 ‘Marshmallow’ (API level 23)</strong></p>
<p>Go back to the <strong>Build Settings</strong> Window. Click on the ‘Add Open Scenes’ Button. This will add our current scene to the ‘Scenes In Build’ list.</p>
<p>Now, click the ‘Build an Run’ button. </p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/31-unity-build-settings2.png"/></p>
<p>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<strong> file name</strong> for your App. I called mine ‘test’ (you will note that the extension for an Android App is <strong>.apk</strong>)</p>
<p>The build process should then commence…</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/32-build-process.png"/></p>
<p><br></p>
<p>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.</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/33-insert-device.png"/></p>
<p>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)</p>
<p>After the brief Unity Splash screen, you should see the ‘Capsule’ scene in all its VR glory!</p>
<p><img src="http://milanprucha.com/steemit/002-gearvr/34-vr-capsule.png"/></p>
<p><br></p>
<p><br></p>
<p><img src="http://www.milanprucha.com/steemit/001-aboutme/milan-prucha-s.jpg"/></p>
<p>Milan Prucha is a creative coder based in London. He specialises in creating interactive experiences for exhibitions and conferences. His work includes interactive installations, games, Virtual Reality and mobile/tablet apps.</p>
<p>Website: <a href="http://milanprucha.com" target="_blank">milanprucha.com</a>.<br>
Twitter: <a href="https://twitter.com/MilanPrucha" target="_blank">Milan Prucha @MilanPrucha</a></p>
</html>