Get Started with Google VR in Unity

Unity 5.6 makes building Daydream and Cardboard applications for Android easy. This guide shows you how to set up Unity for Google VR development and build a demo scene.

Unity currently does not support building applications for iOS. If you want to build a Cardboard app on iOS with Unity, see the Getting Started with Unity for iOS page.

Prerequisites

  • Install Unity 5.6. Make sure that the "Android Build Support" component is selected during installation (it should be selected by default). If this is your first time developing Android applications in Unity, follow Unity's Android SDK setup.

  • Download the Google VR SDK for Unity. This includes the SDK and demo files.

  • [Daydream] You'll need Daydream hardware to run your app, including a Daydream-ready phone and Daydream headset.

  • [Daydream] You'll also need a second Android phone with the Controller Emulator. This guide refers to it as the controller phone.

Import the SDK

  1. Open Unity, creating a new 3D project.

  2. Import the Google VR Unity package by going to Assets > Import Package > Custom Package. Select the GoogleVRForUnity.unitypackage file you downloaded and click Open. Make sure all the boxes are checked in the Importing Package dialog and click Import. Accept any API upgrades if prompted.

Configure build settings

  1. Go to File > Build Settings, select Android as the platform by highlighting it in the Platform list and click Switch Platform.

  2. Click the Player Settings... button, revealing the PlayerSettings section in the Inspector. Find the Other Settings section and do the following:

    • Enable Virtual Reality Supported. In the Virtual Reality SDKs section that appears below, select the + icon, then select Daydream or Cardboard as appropriate to add it to the list.

    • Enter a package name into the Bundle Identifier field (for example, com.yourdomain.VRUnityDemo).

    • Set the Minimum API Level drop-down menu to [Daydream] "Android 7.0 'Nougat' (API level 24)" or [Cardboard] "Android 4.4 'Kit Kat' (API level 19)" as appropriate.

Load and preview the demo scene

  1. In the editor's project pane, navigate to the Assets > Google VR > Demos > Scenes folder and open the GVRDemo scene.

  2. [Daydream] Connect your controller phone (not the headset phone) to your computer using a USB cable. Start the Controller Emulator app on your controller phone.

  3. Press the Play button in Unity. In the Game view you should see a stereo rendering with one or more cubes.

  4. Press and hold the Alt key and move your mouse to simulate turning your head in VR. Press and hold the Control key and move the mouse to tilt your view.

    • [Daydream] Use the controller phone as a Daydream controller emulator.
    • [Cardboard] Click the mouse to send a trigger input.

Build and deploy the demo scene

  1. Connect (only) your headset phone to your computer using a USB cable.

  2. Click the Build and Run button.

Put the headset phone in your viewer and try out the demo!

What next?

Learn more about the Google VR SDK for Unity. If you want to build Daydream applications, read our guide on the Daydream Controller API in Unity.