O'Reilly logo

Unity 4.x Cookbook by Matt Smith, Chico Queiroz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding customizable volume controls

Sound volume adjustment can be a very important feature, especially if your game is a standalone. After all, it can be very frustrating needing to access the operational system volume control. In this recipe, we will create a sound volume control GUI that can be switched from a single volume bar to independent music and effects controls.

Getting ready

For this recipe, you'll need the soundFX.wav and soundtrack.mp3 audio files, available in the 0423_06_02 folder.

How to do it...

To add volume control sliders to your scene, follow these steps:

  1. Import the required soundtrack.mp3 audio file.
  2. In the Project view, select the soundtrack.mp3 file. Make sure the 3D Sound option of the Audio Importer (in the Inspector view) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required