So I was wondering if anyone actually manages audio sources for scenes that have lots of things going on. An example would be a first person shooter that has lots of gunfire, explosions, etc playing at the same time.
One strategy would be to just attach an audio source to each object that makes a sound, set a priority, and let Unity play all sounds. Or maybe use do a PlayOneShot on from a single audio source multiple times (assuming the sound doesn’t need to loop). If there are more audio sources than channels, then Unity has a way of playing the high-priority sounds first and then…possibly playing the lower-priority ones? A higher-priority sound would probably be a big explosion, while lower-priority would be pistol fire.
I’ve had problems in the past where Unity’s audio engine would just sort of “shut down” temporarily if too many sounds are playing. So I thought of another way: have a way of prioritizing the sound types yourself via some kind of audio management system. When new sound effects are playing, they are played through a finite set of audio sources allocated by the manager…higher priority sounds get played over lower-priority ones (or ones that finished playing already).
The second solution is a bit nasty, so I’m wondering if it’s necessary at all. I wondering what approach people take here.