For VR user experience related tips, check out this article
The tools, SDKs, and platforms used in VR development are currently in a state of rapid evolution, so any tech tutorial will probably be obsolete within weeks. Depending on when you’re reading this, the information could be completely accurate, somewhat correct, or completely wrong. With that warning out the way, let’s forge ahead! These tips will assume that you’re using Unity 5.4.4p1 and the commercially available GearVR headset with a Galaxy S6, S7, or Note 5. Depending on when you’re reading this, newer versions of Unity may also work.
- If you haven’t already done so, set up your machine for Android development.
- Create an Oculus developer account. The developer account will give you access to assets, tools, and tutorials that you’ll need to develop your application.
- Start a new 3D project in Unity and change the build settings to Android. Change Texture Compression to ETC2 (GLES 3.0).
- Download the Oculus OVR Unity Utilities and import the package into your project (Assets -> Import Package -> Custom Package…).
- It’s beyond the scope of this guide to go through a sample app, but there’s plenty of examples online. Samsung published a pretty good one. Oculus also has a version of their famous “Roll a ball” tutorial for VR.
- When you’re ready to publish to your phone, make sure that you’ve got VR Supported in your Player Settings.
- You’ll also need to make sure that your Samsung phone is set up for Developer Mode, has USB Debugging enabled, and that you’ve generated an OSIG file for your phone.
Build the app to your phone, and you should be prompted to insert the phone into your GearVR! Enjoy your new virtual world!
Interface: You can navigate a scene or trigger actions with the GearVR touchpad or a Bluetooth game controller. The touchpad will look like mouse input to unity so use the traditional Input API for touchpad events. The “Back” button on the side of the GearVR Headset will look like the “esc” key in Unity.
Performance: It’s hard enough to optimize a traditional mobile game, but VR in particular is extra demanding. Because you are rendering each eye, many graphics calculations are doubled, and the user experience in VR can degrade quickly if the frame rate drops below 60fps. (GearVR’s Timewarp will help somewhat.) In order to maintain a consistent frame rate, you’ll need to forgo any “bells and whistles” effects as much as possible. Your app will be some combination of concessions, in favor of other attributes. For example: Do you have a high poly count? Maybe you’ll have to turn off shadows, or bake all of your lighting. Do you have a lot of particles? You might need to remove that beautiful shader from your scene. Here’s a list of areas to look at when you’re deciding what you need, and what can go:
- Shadows, and shadow quality
- Number of real-time lights
- Batch count (try to keep below 75)
- Triangle count (try to keep below 50,000)
- Post-Image effects
- Complex Shaders, in particular shaders that render transparency.
- Mixing shaders in your scene (try to pick 2–3 different shaders at most)
- Tons of huge Textures
Whenever possible, make objects static in your scene. If you really know what you’re doing, using texture atlases will definitely improve performance.