You get one Master, one Music, and one SFX control that works on-device, survives restarts, and feels right because your slider maps to decibels instead of linear amplitude. This prevents a loud jump in the mid-range and gives predictable volume behavior on small screens and low-power phones.
Below is a copy/paste-ready C# snippet you place in a settings UI. It uses AudioMixer.SetFloat and converts a 0–1 UI slider to decibels with a safe floor at -80 dB. Make sure your exposed parameter names match: “MasterVol”, “MusicVol”, “SFXVol”. This follows the Unity Manual and the Scripting API AudioMixer.SetFloat pattern.
Implementation (start):
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
– Use dB mapping (20 * Log10) with a -80 dB floor to avoid NaNs and achieve mute.
– Expose parameters: MasterVol, MusicVol, SFXVol and call AudioMixer.SetFloat from C#.
– Persist slider values to PlayerPrefs to survive restarts and keep CPU/memory low.
Get working volume sliders fast with exposed Audio Mixer parameters
Set up three clean volume controls so players get predictable levels and settings that persist across sessions.
First, create a dedicated folder in your Project, for example: Assets/Audio/Mixers. Then use Project > Create > Audio > Audio Mixer and name the asset MainMix. Open MainMix and add two child groups under Master named Music and SFX.
Create and expose group attenuation
Expose the Attenuation (volume) parameter on Master, Music, and SFX. Rename the exposed parameters exactly to MasterVolume, MusicVolume, and SFXVolume. Mismatched names are the most common beginner trap.
Wire UI sliders and convert to decibels
Keep sliders as linear 0–1 for UX. In code convert the value to dB with 20 * Mathf.Log10(Mathf.Max(value, 0.0001f)) and clamp to a floor like -80 dB. Call AudioMixer.SetFloat with the exposed parameter name to apply volume.
Persist player settings safely
Store slider values using PlayerPrefs keys: MasterVol, MusicVol, SFXVol. On scene load, read, clamp, and use SetValueWithoutNotify on the UI control before applying to avoid double-calls and a 1-frame loud blast.
- Design larger slider handles and spacing for touch screens; the code stays the same.
- Verify each group has sources routed away from Master so sliders actually affect output.
- See Unity Manual “Audio Mixer” and Scripting API
AudioMixer.SetFloat.
| Group | Exposed Parameter | PlayerPrefs Key | Default (linear) |
|---|---|---|---|
| Master | MasterVolume | MasterVol | 0.8 |
| Music | MusicVolume | MusicVol | 0.7 |
| SFX | SFXVolume | SFXVol | 0.9 |
Create an Audio Mixer that scales with your project structure
Keep the Audio Mixer visible and docked so you can iterate mixes in real time during play. Open it via Window > Audio Mixer and dock the window next to Scene or Game for fast feedback. Live testing prevents tweaks that sound right in silence but fail in-context.
Design a bus layout that grows with the project. Make Master the top bus, then add Music and SFX as direct child groups. When you need granularity, add child buses like SFX/UI, SFX/Gameplay, and SFX/Ambience.
Naming and hierarchy rules
Use consistent names: Master, Music, SFX, and clear child labels. Keep every group routed upward so you can reason about where effects and attenuation live. This rule avoids hidden routing that breaks your sliders.
Color-code and map to UI
Assign colors to group strips for quick visual debugging in Play Mode (example: Master=red, Music=orange, SFX=cyan). Also match mixer categories to user-facing volume controls to prevent later hacks.
- Keep test groups out of shipping mixers.
- Avoid duplicate names like Music2; prefer descriptive suffixes if needed.
- Use the docked window to iterate and document group purpose in a project folder under Assets.
| Group | Purpose | Suggested Color | When to add child buses |
|---|---|---|---|
| Master | Global control and final effects | Red | Only if platform-specific routing is required |
| Music | Background tracks and ducking receiver | Orange | When you split stems or need separate tracks |
| SFX | Gameplay and UI hits, sends for reverb/ducking | Cyan | Start children at ~10 assets per category (UI/Gameplay/Ambience) |
| SFX/UI | Menus, clicks, and UI feedback | Light blue | Create early if you plan separate UI volume control |
Route Audio Sources into the right groups so your mix controls actually work
Routing mistakes are the single biggest reason your category sliders seem to do nothing. Before touching code, verify each audio source routes to a labeled group so the corresponding slider affects output.
Send background music to the Music group
Create a Background Music GameObject, add an audio source component, set Loop, and assign Output to your Music group. That makes the music slider control this track directly.
Route gameplay sources into SFX (and consider a UI child group)
Point weapons, impacts, and pickups at the SFX group. If UI elements must stay audible when combat is loud, create SFX/UI as a child and route UI sources there.
Prefab workflow gotcha
If the source comes from a prefab, edit the prefab asset or root prefab output. Changing a single scene instance won’t persist when objects respawn.
Verify routing during Play Mode
- Trigger a known SFX and watch the SFX group meter move.
- Mute Music; confirm only background music stops.
- If only the Master meter moves and category meters stay dead, everything is routed to Master and your sliders will feel broken.
Build a compact test scene with buttons that play clips so you can verify routing on-device without loading a full level.
unity audio mixer mobile game sound level targets and practical mixing workflow
Target clear decibel ranges for your music and effects so mixes translate to cheap speakers and headphones. Start with meter goals and adjust in Play Mode while you hear real gameplay.
Use attenuation with real meter targets
Set Music group peaks around -10 to -6 dB and SFX peaks near -3 to 0 dB for presence without clipping. For background music aim lower so it never masks hits.
Quick ducking setup
- Add a Duck Volume effect on the Music group.
- Add a Send on the SFX group and set Receive to MusicDuck Volume with Send Level at 0 dB.
- Starting tuning: Threshold ≈ -45 dB, Ratio ≈ 250%, Attack/Release near 0, then refine by ear.
What to listen for and mobile checks
On a mid-range Android speaker and cheap earbuds, listen for clarity: fast attack keeps hits audible; slower release prevents the music from “pumping.” If the track breathes too much, lengthen release rather than boost ratio.
| Target | Starter Value | What to listen for |
|---|---|---|
| Music peaks | -10 to -6 dB | Background stays present but not masking |
| SFX peaks | -3 to 0 dB | Hits cut through without clipping |
| Ducking | Threshold -45 dB, Ratio 250% | Music dips cleanly when hits occur |
Warning: each real-time effect costs CPU and battery. Limit chains across many groups and test performance on target devices early in development time.
Use Views and Snapshots to manage complexity and game states
Use Views and Snapshots so you can jump to the tracks you care about and recall exact mixes for menu, play, and paused states. This keeps the mixer usable as the project grows and prevents wasted time scrolling long strips in the window.
Create Views for Music vs SFX
Make a Music view that shows only music-related groups and an SFX view that shows effects. Add an Everything view for sanity checks. Views are visibility presets for the strip layout and speed up iteration when you edit mixes in play.
Create Snapshots for Menu, Gameplay, and Paused
Create three snapshots: Menu (lighter music, softer effects), Gameplay (full mix), Paused (muted bed or low-pass). Typical parameters you change are group attenuation, an optional low-pass on the music bus, and ducking intensity.
Transition snapshots from code without pops
Transition snapshots with a short crossfade instead of an instant swap. Use 0.1–0.3 seconds for UI state changes to avoid clicks. Drive transitions from your state manager (menu controller or pause button) so changes are deterministic and testable.
- Tip: Edit in Play Mode to tune snapshots quickly.
- Warning: Don’t edit the wrong snapshot—otherwise your changes won’t appear where you expect.
| Snapshot | Starter Transition | Common Parameters Changed |
|---|---|---|
| Menu | 0.15 s | Music attenuation, SFX attenuation |
| Gameplay | 0.2 s | Full group levels, duck send |
| Paused | 0.1 s | Low-pass, mute/attenuate groups |
Mobile performance considerations for Unity audio: memory, CPU, battery, and file settings
On phones you must balance RAM, CPU, and battery when choosing how clips load and play. Poor choices cause stutters, thermal throttling, and shorter sessions.
Import types and when to use them
Pick Streaming for long tracks to save RAM. Use Decompress On Load for tiny UI clicks that must play instantly. Choose Compressed In Memory for mid-length effects to avoid decode spikes at runtime.
Compression, sample rate, and mono/stereo rules
Use Vorbis/MP3 for long music. Keep short sound effects lightly compressed to avoid artifacts. Drop sample rate for incidental hits; many SFX work fine at 22 kHz.
Use mono for positional sources like footsteps and impacts. Reserve stereo for beds and non-positional music to halve memory use and preserve spatial cues.
Polyphony, pooling, and effect budgets
Cap concurrent one-shots and reuse audio sources via pooling. This prevents allocations and CPU spikes that drain battery and cause frame drops.
Limit effects chains per group. One or two essential components (ducking, low-pass) are okay. Test on target devices and monitor temperature over time.
| Import Type | Best For | Memory Cost | CPU Cost | When to Pick |
|---|---|---|---|---|
| Streaming | Long music tracks | Low RAM | Moderate I/O | Background music, long loops |
| Decompress On Load | Tiny UI clicks | Moderate (once) | Low at runtime | Short, instant-play clips |
| Compressed In Memory | Mid-length effects | Medium | Higher decode cost | SFX where latency matters but RAM is limited |
Common beginner mistakes that break mixer-based volume controls
A few small setup errors can make your volume controls feel broken on device. Below are the usual failures, clear symptoms you will see, and exact fixes to apply in your project.
Using linear slider values directly
Symptom: 0.5 feels much louder than “half” and changes jump unpredictably. Fix: convert the UI value to decibels with 20 * Log10(max(value, 0.0001f)) and clamp to -80 dB. That maps perceived loudness to the mixer scale.
Forgetting to expose parameters or mismatching names
Symptom: calling SetFloat does nothing. Cause: your script uses “MusicVolume” but the exposed name is “MusicVol”. Fix: copy/paste the exposed parameter name into code and store the string in a single constant to avoid typos.
Leaving AudioSources routed to Master
Symptom: the music slider appears dead while the master meter moves. Fix: set each audio source Output to the Music group and update prefabs so spawned instances inherit the route.
Overlapping background music instances
Symptom: music doubles after scene loads and the mix sounds wrong. Fix: enforce a single background music owner (DontDestroyOnLoad or a central manager) and stop or replace duplicates on load.
Importing music as PCM by default
Symptom: build size and memory spike; device stutters. Fix: use compressed formats and streaming for long tracks and test decoding on device.
- Two-minute checklist: group meters respond, exposed names match your code, only one background music plays.
| Failure | Visible Symptom | Quick Fix |
|---|---|---|
| Linear slider used raw | Volume jumps; perceived levels wrong | Convert with 20*Log10 and clamp to -80 dB |
| Parameter name mismatch | SetFloat has no effect | Copy exposed name to a single constant and use it in code |
| Sources routed to Master | Category slider seems inactive | Set Output on prefab to the correct group |
| Multiple music instances | Tracks stack; mix overloads | Use one owner (manager or DontDestroyOnLoad) |
Conclusion
Finish strong: confirm sliders, routing, and performance on target phones before shipping.
Keep one mixer asset with Master, Music, and SFX groups, expose parameters, and have UI sliders write dB values that persist for the player. Verify every Audio Source routes to its group and your exposed names match code exactly.
Use meters in Play Mode, set music lower than effects, and tune ducking with a Duck Volume plus a Send for clearer transient cues on small speakers.
Prioritize import modes, compressed files, capped polyphony, and minimal effects chains to protect battery and CPU. Next step: add a UI group if needed, then create Menu/Gameplay/Paused snapshots and drive clean transitions from your state code.

Game developer with over 10 years of professional experience specializing in the mobile sector. George’s journey began with a passion for indie development, leading him to contribute to several successful mobile titles, including the critically acclaimed puzzle-platformer ChronoShift and the top-down strategy game Pocket Empires.
