The Google VR SDK for Unity provides support for the Daydream controller, including the following capabilities:
Arm model: Mathematical model that predicts the location of the user's controller, based on the controller orientation and by using virtual shoulder, elbow, wrist, and pointer joints.
Input system: Integration with Unity's standard
EventSystem. Integrates with the laser pointer, includes custom graphic and physics raycasters and reticle visualizations to allow users to interact with Canvas UI elements and game objects in your scene.
Reskinnable visualizations: Default visualizations that can be reskinned if desired:
Controller: 3D model of the Daydream controller model that indicates which button the user is currently pressing and/or where the user is currently touching the controller touchpad.
Laser and reticle: Displays a laser and reticle to help users interact with the VR environment.
Tooltips: Customizable tooltips indicating how to use the controller buttons and touchpad.
The SDK includes several prefabs to support the Daydream controller and integrate with the Unity's Input Sytem.
Controller and Input System prefabs
To include Daydream controller support in your app, add the following prefabs to your scene:
|Prefab name||Location in scene||Description|
|GvrControllerMain||Anywhere in scene||Main controller prefab, responsible for managing controller state.
|GvrControllerPointer||Sibling to the Main Camera||Daydream controller prefab.
Provides controller, laser, and reticle visualizations and serves as attachment point for tooltips and custom visualizations.
|GvrEventSystem||Anywhere in scene||Drop-in replacement for Unity's Event System prefab that enables the Daydream controller to use the Unity event system.
|GvrEditorEmulator||Anywhere in scene||Editor play mode camera controller.
Lets you simulate user's head movement in the editor with your mouse or trackpad.
|GvrInstantPreviewMain||Anywhere in scene||Editor play mode Instant Preview controller.
Lets you stream a stereo preview to your phone and use a physical Daydream controller in the editor.
Main Camera Near clipping plane
Unity's default Camera game object is configured with the Near clipping plane
0.3 (30cm). To prevent the rendering of the Daydream controller from
being clipped, lower the Near clipping plane value. We recommend using
In order to ensure correct rendering of the controller, make sure the GvrControllerPointer prefab exists as a sibling to the Main Camera game object. For example, create an empty Player game object and attach both prefabs to this game object.
Any scripts which would normally affect the Main Camera transform should instead modify the Player transform instead.
The resulting scene will look something like this:
In-editor emulation options
To test your app in the editor, choose from the following options:
|In-editor emulation||Hardware requirements||Description|
Daydream Standalone headset
|Use Instant Preview on the headset device. Connect the device to the Unity Player via USB. Daydream controller input comes from the keyboard, through the GvrControllerEmulator.|
||Use Instant Preview on the headset device, in Controller only mode. Connect the headset device to the Unity Player via USB. Bluetooth pair the device to the Daydream controller.|
|Headset and controller emulation||Use Instant Preview on the headset device, in Full VR preview mode. Connect the headset device to the Unity Player via USB. Bluetooth pair the headset device to the Daydream controller.|
Graphic and Physics raycasters
The SDK includes drop-in replacements for Unity's standard graphic and physics raycasters.
|GvrPointerPhysicsRaycaster||Drop-in replacement for Unity's PhysicsRaycaster.
Uses the current
|GvrPointerGraphicRaycaster||Drop-in replacement for Unity's GraphicRaycaster.
Uses the current
Customizing controller visualizations
The GvrControllerPointer prefab is designed to be customized.
Add custom visualizations to the controller
Use one of the following options:
Customize the prefab directly.
Add one or more custom prefabs to the GvrControllerPointer prefab's ControllerVisual >
GvrControllerVisualcomponent's Attachment Prefabs list.
The prefabs in this list will be cloned and attached to the controller at runtime.
Configure a raycast mode
Use the GvrControllerPointer prefab's Laser >
component Hybrid, Camera, and Direct buttons to select the desired
raycast mode and apply raycast mode defaults.
Customize default laser and reticle visualizations
To turn off the default visualizations:
- Disable or remove the GvrControllerPointer prefab's
- Attach your own custom game objects or components to the prefab.
To customize the default laser and reticle visualizations' color, size, and behavior, adjust the prefab's subcomponents' properties in the inspector.
Customize controller tooltips
Add your custom tooltips prefab to the GvrControllerPointer prefab's
GvrControllerVisual component's Attachment Prefabs
Create your own tooltips or use one of the provided prefabs:
|GvrControllerTooltipsSimple||Performance optimized tooltips, rendered using a graphics texture.
To customize this prefab, make a copy of the prefab and replace or update the provided TooltipsSimple material to use a custom texture. Use the included
|GvrControllerTooltipsTemplate||Flexible dynamic tooltips, rendered using a Canvas UI.
To customize this prefab, make a copy of the prefab, expand the game objects under the prefab's Canvas game object and customize the tooltips' Text components.
The prefab includes four tooltip labels: TouchPadOutside, TouchPadInside, AppButtonOutside, and AppButtonInside. These label names correspond to locations, relative to the controller, and the user's handedness preference. Use GoogleVR > Editor Settings > Handedness to test different user preferences while in the editor.
Customize arm model
The GvrControllerPointer prefab's
Arm Model property to specify the arm model for the controller. By default,
the prefab uses its own
GvrArmModel settings assume that the user will hold and use the
controller like a laser pointer. If your app requires using the controller
for different actions, such as swinging a bat or catching a ball, adjust the arm
model settings appropriately.