Getting Started with Unity for Cardboard

Unity provides many tools for creating 3d interactive experiences, which is ideal for creating a virtual environment for Google Cardboard.

The goal of this tutorial is to introduce you to building Cardboard apps for iOS and Android with Unity. No prior experience with Unity is assumed.

Step 1: Setup your development environment

Download and install all the tools needed to build 3d worlds with Unity.

You will need:

You can also checkout the git repository for the Cardboard SDK at:

https://github.com/googlesamples/cardboard-unity

Cardboard for Android Requirements (optional)

Cardboard for iOS Requirements (optional)

Step 3: Setup a new project in Unity

1.    Open Unity and create a new project.

2.    Import the Cardboard SDK

A. Go to Assets -> Import Package -> Custom Package

B. Select the CardboardSDKForUnity unitypackage that you the Cardboard SDK folder that you downloaded from GitHub in Step 1 and click Open.

i. Make sure all boxes are checked under “Importing Package” and click Import.

ii. If you receive a warning that the APIs will automatically be upgraded, accept it and continue.

3.    Repeat step 2 for the CardboardDemoForUnity unitypackage (also in the Cardboard SDK folder)

4.    Import the assets.

A. In the editor’s Project pane, navigate to the Assets -> Cardboard -> DemoScene folder and open DemoScene.

B. You should see a textured grid pane with a cube floating above it.

5.    Run the demo in Unity.

A. Press Play and you should the game view showing a stereo rendering of a red cube.

i. Press Alt and move the mouse to simulate moving your head horizontally and vertically.

ii. Press Ctrl and move the mouse to simulate tilting your head from side to side.

Step 4: Build the Unity project for iOS devices

1.    Setup the Build Settings.

A. Open up the build settings from Unity under File -> Build Settings

B. Select iOS under Platform. After selecting iOS, click the Switch Platform button

2.    Setup the Player Settings

A. Click Player Settings to open the PlayerSettings panel in the Inspector.

i. In PlayerSettings, at the bottom under “Settings for iOS” click Resolution and Presentation to expand the panel and set the Default Orientation to Landscape Left.

ii. Click Other Settings to expand the panel and find the Bundle Identifier field. Enter a valid package name for your application (such as com.yourorganization.cardboarddemo).

3.    Run on your iOS device.

A. Plug in your iOS device and click Build and Run.

i. Look around the scene to find the cube. When you look at it, it turns green.

ii. Pull the Cardboard trigger (or tap the screen) to teleport the cube to a new location. Try to find it again.

Step 5: Build the Unity project for Android devices

1.    Setup the Build Settings.

A. Open up the build settings from Unity under File -> Build Settings.

B. Select Android under Platform. After selecting Android, click the Switch Platform button.

2.    Setup the Player Settings

A. Click Player Settings to open the PlayerSettings panel in the Inspector.

B. Click Other Settings to expand the panel and find the Bundle Identifier field. Enter a valid package name for your application (such as com.yourorganization.cardboarddemo).

i. Under “Resolution and Presentation”, check that the default orientation is set to Landscape Left.

3.    Run on your Android device.

A. Plug in your Android device and click Build and Run

i. If prompted for the location of Android SDK, select the unzipped SDK from Step 1.

ii. Look around the scene to find the cube. When you look at it, it turns green.

iii. Pull the Cardboard trigger (or tap the screen) to teleport the cube to a new location. Try to find it again.

Step 7: Keep Learning

Congratulations! You have built your first Cardboard app in Unity, but that is just the beginning. Browse some of the following resources to continue exploring how to build more advanced projects in Unity for Cardboard.

Cardboard in Unity

Learn Unity

Thank you to the following tutorials for informing this blog post.