Using Spatial Audio

To get started with Google VR's spatial audio support in Unity, add the GvrAudioListener component to the same GameObject that Unity's AudioListener component is attached to. In most cases this will be the Main Camera.

When you press Play in the Editor, GvrAudioListener initializes the Google VR Audio system automatically.

Adding sources with Google VR Audio support

To add an audio source with Google VR Audio support, attach a GvrAudioSource component to a GameObject. Then, you can modify the properties of the source in similar way to Unity’s AudioSource and press Play to hear the outcome immediately over headphones.

You can also add the GvrAudioSource prefab provided in the plugin package directly to your scene. This will add a GameObject with a generic GvrAudioSource attached to it.

Finally, the GvrAudioSoundfield prefab allows you to use ambisonic spatial audio which responds to head rotations.

Adding room effects

The Google VR Audio system offers a sophisticated yet easy-to-use room simulation component to enhance the VR experience. In order to add a room to your project, add the GvrAudioRoom prefab to your scene. It consists of a GameObject with a generic GvrAudioRoom component attached to it.

You can also attach a GvrAudioRoom component manually to any GameObject you wish to use. To do so, select the GameObject in the Hierarchy panel, and select Add Component > Google VR > GvrAudioRoom in the Inspector panel. This component automatically takes the Transform properties of the GameObject set in the Inspector panel and simulates environmental effects accordingly. You can also adjust additional room properties to get the correct sound from a room. The GvrAudioRoom interface allows you to select surface materials which affect the sound in the scene according to their physical properties, alongside reflectivity and reverberation settings to fine tune the desired environment.

GvrAudioRoom applies the corresponding environmental effects whenever the GvrAudioListener component’s GameObject is inside the boundaries of the room. A yellow rectangular box Gizmo shows the adjusted boundaries of the room in the Scene view.

Integrating Google VR Audio with an existing project

  1. Follow the guidelines in this document.

  2. Replace each existing AudioSource in your scene with GvrAudioSource using the Hierarchy and Inspector panels. Modify the source properties accordingly. For scripts, renaming AudioSource to GvrAudioSource should be enough.