unity-game-enginefmod

Does unloading a bank destroy/release all instances in that bank


Is it safe to unload a bank as a means to releasing all related instances? I'm VERY new to FMOD and trying to get my bearings.

I play music across scenes in Unity and so I want to know if I should worry about holding on to instances, or just unload the bank.


Solution

  • Quoting from FMOD Studio API guide:

    If the bank containing the sample data was loaded via Studio::System::loadBankMemory then the system must immediately unload sample data when the bank is unloaded. This may lead to playback errors if any instances of events in the bank are still playing. This can occur even if multiple copies of the sample data are loaded from different banks and only one of the copies is being unloaded.

    So, basically, if you are explicitly loading banks via Unity Integration package for Fmod's API, you have to be careful with bank unloading as it can create unwanted behaviors and null references. But if you are doing a specific scenario, something like unloading the bank as the scene unloads, and you are absolutely sure that no instance is going to reference the bank, I cannot see a reason to not do that. Moreover, fmod's unity integration provides event triggers for bank loading and unloading. Take a look at this: Studio Bank Loader