How to Play Sound Effects in Unity

Rob George
2 min readApr 23, 2021

Day 26 — Aspiring Game Creator

2D Game Dev: Galaxy Shooter

Slider values are written to PlayerPrefs

Objective: Implement Unity’s Audio Mixer with UI Sliders, saving values to Player Prefs to save settings.

All audio in Galaxy Shooter is being played by individual Audio Sources. Any adjustments requires multiple code changes or going back and forth between Audio Sources.

Unity’s Audio Mixer makes it much easier to manage!

From the moment of setup, the Audio Mixer allows for fast creation of Mixer Groups and already having an idea of what the initial sound requirements are, these can be quickly created and grouped and routed.

Above the Master will take the output of sub-groups of Music and SFX. In turn the SFX will take all the sound effects from the Explosion, Laser, Power-Up & Repairs groups.

The Player’s Options UI will have three volume sliders: Master (Main), Music & SFX.

The Main Music can be muted via a toggle, muting both Music and SFX.

Or Music and/or SFX volume can be muted with the sliders.

Unity’s Audio Mixer does much more than routing the individual mixers.

Effects can be added to each and every mixer as well as Effect Groups created and sounds passed through them.

As with many aspects of Unity there are an abundance of options to get to know!

--

--