I’m encountering a rather strange bug with unity in combination with FMOD:
When disabling unity audio completly (through Edit->Project Setttings->Audio->Disable Unity Audio an option in the player settings is ignored. The option I’m referring to is in Edit->Project Settings->Player->Other Settings->Mute Other Audio Sources. It will always mute other audio sources, no matter if enabled or not.
This does not happen when unity audio is enabled and it also does not happen when unity audio is disabled, but no FMOD is included in the project. I sadly can’t tell, is this a unity bug or an FMOD bug?
If it is an FMOD bug, was it already fixed? (I’m using 1.09.04)
I checked both the unity release notes as well as the fmod release notes, but didn’t find anything addressing the problem. I first wanted to send a bug report to unity, but then noticed, that the problem does not occur when FMOD is not included in the project.
Please let me know if the problem is on fmods side and if I can easily fix it
iOS uses AusioSession’s to determine the behavior of apps, normally Unity will set the AudioSession and category automatically but it seems this is disabled when the Unity audio is disabled.
You can set the AudioSession to mix with background music one of two ways:
You can manually change the AudioSession Category in code to AVAudioSessionCategoryAmbient (see the link below for more info),
or in the Unity Player Settings (or Xcode) set the background mode to “Audio, AirPlay and Picture in Picture” (also shown in the link).
Ah, very interesting, I will check that! The only thing I’m wondering now is why it does work when Unity audio is disabled and fmod is not included?
Thanks a lot for the info and I’ll let you know if it worked
After a lot of struggeling I got swift working with unity and I also managed to call the referenced method from unity in order to set the mute option. Works quite well, but has an issue: When playing music and then opening the app for the first time, Unity sets the audio option before I can. This results in the music being paused (ios itself does that). So I can overwrite it, but the player will have their sound paused at the start of the app.
The other part you were pointing me at is meant for apps that themselves want to play audio in the background, not the other way around.
So, I’m not completly sure why the muting only happens when FMOD is integrated, but it feels more and more like the problem lies on Unitys side. Can you confirm that?
So I got in contact with the unity team and they said it is intended behavior (Case 960222):
The “Mute Other Audio Sources” option only affects the built-in Unity audio settings.
Once users wish to use the FMOD Studio integration they will need to (a) disable Unity audio from the Edit > Project Settings > Audio menu, and (b) manually set the iOS Audio Sessions to allow for background and/or interrupting audio. This is mentioned in the iOS Specific Starter Guide of the iOS API.
If you want the audio from Unity (FMOD) to mix with other system audio, you can override this behavior by setting the AVAudioSessionCategoryOptionMixWithOthers option on the session.
This is necessary so the other sources don’t get paused/muted when the app starts, because of the default setting.
In unity the first thing I can execute is by calling RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad), but this method will still be called after the splash screen. The only option I see right now is to try to drill into the unity application itself in xcode, but I’m wondering if that is really the way to go, it seems quite hacky! Any ideas on where to go from here?