FMOD Unity integration version: 2.01.01
public static bool HasBanksLoaded
{
get
{
return Instance.loadedBanks.Count > 1;
}
}
public static bool HasBankLoaded(string loadedBank)
{
return (instance.loadedBanks.ContainsKey(loadedBank));
}
Note that HasBankLoaded
refers to instance
, rather than Instance
, the former of which does not lazy-init the RuntimeManager
.
To work around this mistake I used the following hack:
IEnumerator Start() {
// Wait for all master banks to load. Ths is requred for web where banks
// are loaded in asynchronously.
//
// https://www.fmod.com/resources/documentation-api?version=1.10&page=content/generated/engine_new_unity/html5_webgl.html
var banks = FMODUnity.Settings.Instance.MasterBanks;
// NOTE: Forcing initialization of FMOD which otherwise does not start due
// to internally referencing `instance` instead of `Instance`.
var _ = FMODUnity.RuntimeManager.HasBanksLoaded;
while (!_isFmodSoundBankLoaded) {
_isFmodSoundBankLoaded = banks.All(FMODUnity.RuntimeManager.HasBankLoaded);
yield return null;
}
This definitely seems like an error, and only showed up (in an otherwise working project) when I removed the FMOD listener component from the scene. Previously it called AddListener
which internally called StudioSystem.setNumListeners
which happened to cause the system to initialize before my first call to HasBankLoaded
.