How to do it...

To make a dynamic soundtrack, follow these steps:

  1. Create a new Unity 3D project.
  2. Import the provided Unity package, DynamicSoundtrack, and the two .ogg files into your project.
  3. Open the Dynamic scene from Project panel folder, DynamicSoundtrack | _Scenes.
  4. In the Project panel, use the Create menu to add an Audio Mixer file. Rename this new file Mixer-music. Double-click it to open the Audio Mixer panel.
  5. In the the Audio Mixer panel Groups section, highlight Master and click the + (plus) sign to add a child to the Master group. Name this child Percussion. Repeat these actions to add a second child of Master, named Synths:
  1. From the Hierarchy view, create a new Empty GameObject. Name it Music.
  2. Create a GameObject in the scene ...

Get Unity 2018 Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.