Setting up for Samsung GearVR

By | June 14, 2017

In the past, I have only worked with PC VR/AR devices such as HTC Vive and Microsoft Hololens. Mobile VR development is totally new for me. I attempted to create Google Cardboard experience last year during Ludum Dare but after having too slow of a progress, I dumped the idea.

To prepare for Oculus launchpad bootcamp, I actually went through some tutorials from Udemy Make Mobile VR Games in Unity with C# for Google Cardboard one week before the event. I only had access to Google Cardboard and Daydream at that time, but it gave me some idea how to build and deploy VR apps from Unity onto the phone.

Then yesterday, as I fought nasty sore throat/cold after the bootcamp trip, I managed to successfully built and deploy simple test scene to the new Samsung S7 phone and the GearVR, yay.

I work on Windows 10 system, so here were the steps for my setup:

Unity:

  • Install the latest Unity. At the moment, I have Unity5.6.1f1, which is the latest release version.

Android development software:

  • Install Java Development Kit (JDK) Most people probably already have Java installed on their machine, but not JDK. Most have JDE, which is Java Development Environment. Make sure to find and install JDK as well, or else Unity will complain when building to android phone. Also, make note of the JDK installation path directory. You will need this later in Unity.
  • Install Android Studio Development Bundle or Standalone Android SDK Tools. I went with the standalone SDK tools, since I will be building mostly in Unity. It doesn’t harm you to install Android Studio as well. I just don’t have too much free space on my hard drive, so I go with minimal requirement. If you do get Android Studio, make sure you download the version that has the SDK or else there’s no point. To download just the SDK, scroll down all the way to the bottom to see different software options. Make note of the Android installation path directory. You will need this later in Unity and when identifying phone device ID. Also, make sure to run the Android SDK Manager and install the corresponding tools and API version.

 

Oculus development software:

  • Install Oculus Utilities for Unity 5. I downloaded OVR Unity utilities version 1.15.0, since I don’t feel like writing everything from scratch.
  • Optional: download and install the Oculus Sample Framework for Unity 5 Project. Do be careful when importing this package though. Make sure not to overwrite the latest Oculus Utilities files, or else you will get tons of Unity errors, which will prevent you from even running any scene.

We’re almost there! To be able to deploy to our shiny Samsung S7 phone, we need to identify and get its device ID, then create an Oculus signature file. Here are what to do:

  • Make sure your phone has developer mode enabled. To to this, go to your phone Settings -> System -> About device -> tap on Build Number 7 times. Just keep tapping until it finally says you’re a developer. Then go back to System -> Developer Options and turn it on. I also turn on Stay awake, USB debugging, and Verify apps via USB. Not sure what the last part does, but it sounds safer. Better safe than sushi.. err, sorry.
  • connect your phone to your working PC though USB cable
  • bring out command prompt window  (hit search icon on desktop, type cmd and enter)

  • go to android sdk installation folder. (Use cd.. to go up a folder, cd foldername to go in a folder. My installation is at c:\Program Files (x86)\Android\)
  • Go into android-sdk\platform-tools\ folder (my full path is c:\Program Files (x86)\Android\android-sdk\platform-tools\)
  • type ‘adb devices’ (without the ‘ ‘). This will give you the device ID

Most of the prep work is down. Now in Unity, do these steps:

  • Go to Edit -> Preferences -> External Tools
  • Copy and paste the path to Android SDK tool (mine is C:/Program Files (x86)/Android/android-sdk )
  • Copy and paste the path to Java JDK tool (mine is C:\Program Files\Java\jdk1.8.0_92 )

 

  • Go to File -> Build Settings -> Player Settings
    • Under Other Settings, enable Virtual Reality Supported. Use Oculus Virtual Reality SDK
  • If you’re using spatial audio, go to Edit -> Project Settings -> Audio. On Spatializer Plugin, pick Oculus Spatializer
  • Remember the signature file you created? Place a copy of it under Project/Assets/Plugins/Android/assets/

 

Now create your test scene

  • remove current Main Camera. Drag and drop OVRCameraRig prefab from OVR -> Prefabs folder (part of the Oculus Utilities package. Import this if you haven’t done so.)
  • Create a new 3D object -> Cube, place it 2-3 unit in front of the camera.
  • Save this scene as ‘test’
  • Go to File -> Build Settings, hit Add Open Scenes button to add the scene to the list
  • Still in Build Settings, under Platform, select Android and hit Switch Platform. Let Unity does its thing for a minute or so.
  • Once Unity finished, and your phone is still connected, hit Build And Run. You will be prompted to name and save the apk file. I usually create a new folder called Build and save the apk there.

  • Once Unity finish building, the phone will load the file right away. Just place it in GearVR and give it a test.

Hopefully this guide helps. See you next time.