Google Daydream Hello World Tutorial

By Ruiqi Mao

Requirements

This tutorial assumes that you have completed the Google Cardboard Interactivity tutorial.

You will also need a Google Daydream-capable device, along with a Daydream headset and Instant Preview installed on the device (https://developers.google.com/vr/develop/unity/instant-preview).

Tutorial

 1.   Create a new 3D project in Unity.

2.   Under File > Build Settings, change the target platform to Android and open the Player Settings.

3.   Under "Other Settings", give your application a package name and change the minimum target API to Android Nougat 7.0.

4. Under "XR Settings", add Daydream as a supported platform.

5.   Import the GoogleVR asset package the same way you did in the Cardboard Hello World tutorial.

6.   Add the GvrControllerMain, GvrEditorEmulator, GvrEventSystem, and GvrInstantPreviewMain prefabs to the top level of your scene hierarchy.

7.   Create an empty object in the scene hierarchy and name it "Player" (Right click in the hierarchy > Create Empty). Drag the Main Camera into the new object, and drag a GvrControllerPointer prefab into the Player object as well. This allows the player to visualize where the Daydream controller is pointing.

8.   Make sure the Player object and the Camera object are both at (0, 0, 0).

9.   Create a cube (Right click in the hierarchy > 3D Object > Cube) and place it at (0, 0, 5).

10.   Now we're going to make it so that we can interact with the cube and drag it around with our controller! Start by attaching a GvrPointerPhysicsRaycaster to our Main Camera like we did in the Cardboard Hello World tutorial.

11.   Now, attach an EventTrigger component to the cube. Then, create a new C# script (we'll call it "CubeBehavior"), and attach it to the cube as well.

12.   Open up the CubeBehavior script and place the following in:

13.   Now we can test! Attach your Daydream-capable device to your computer, open up the Instant Preview application, and hit Play in the Unity editor. After syncing the controller, you should be able to move the cube around with your controller!