Adding volume control with Audio Mixers
Sound-volume adjustment can be a very important feature, especially if your game is a standalone. After all, it can be very frustrating for players to have to access the Operating System volume control. In this recipe, we will use the Audio Mixer feature to create independent volume controls for Music and Sound FX.
Getting ready
For this recipe, we have provided a Unity package named VolumeControl.unitypackage
, containing an initial scene featuring soundtrack music and sound effects. The file is available inside the 04_10
folder.
How to do it...
To add volume control sliders to your scene, follow these steps:
- Create a new Unity 3D project.
- Import the provided Unity package, Volume, into your project.
- Open the Volume scene from Project panel folder, VolumeControl |
_Scenes
. - Play the scene and walk toward the semitransparent green wall in the tunnel, using the W A S D keys (press Shift to run). You will be able to listen to:
- A looping music soundtrack
- Bells ringing...