I have an audio source playing ambient noise with priority 0, high priority. This is specifically recommended in unity documentation for things like music.
I have a bunch of other objects that I’m spawning that have their own audio sources. You’ll pretty much never hear more than a few playing at once, but their priority is all lowest, 256. They had their PlayOnAwake set to true (on accident) and so were playing when spawning in, all out of “earshot”. But this audio was canceling out my ambient audio.
Following breadcrumbs, I came to be running this code:
private void Start()
{
StartCoroutine(DebugTesting());
}
IEnumerator DebugTesting()
{
yield return new WaitForSeconds(5f);
audioSource.Play();
if (audioSource.priority == 0)
Debug.Log(audioSource, audioSource.gameObject);
}
When my objects all spawn in, after 5 seconds, my priority 0 ambience gets cut off and the debug log returns nothing because all the object’s audio sources are priority 256. I can make it so they don’t spam play all these sources, but I’m trying to understand what’s wrong and cannot figure it out.