Hi,
Am new to FMOD and am wondering if i’m not fully understanding the usage of Runtimemanager.LoadBank().
From my understanding, grouping events into banks is good to do, as you can load/unload unnecessary events.
I plan on having one bank per enemy in my game, so that if an enemy isn’t in a level, i don’t waste memory loading their sounds, however for the life of me i cannot get loading the banks to work properly.
Since i will have one bank per enemy ( and a generic “Enemy” bank for shared sounds) I want to store a string to the bank’s path in each subclass of my Enemy class, and then load it upon spawning an enemy.
Here is the code i am using just for testing at the moment:
private void Update()
{
if(Input.GetKeyDown(KeyCode.V)) LoadBank("Enemies/Metal/Scissor");
if (Input.GetKeyDown(KeyCode.B)) StartCoroutine(RecheckBank());
}
public void LoadBank(string path)
{
RuntimeManager.LoadBank(path, true);
RuntimeManager.StudioSystem.getBank(path, out var bank));
}
For testing, i am manually loading the bank when i press the button V in update(). i also have a coroutine that prints out all the loaded banks, so i can see when it is loaded.
When i Debug log the FMOD.RESULT from getBank, it is returning: ERR_EVENT_NOTFOUND
but the bank is properly being loaded the first time.
I deload specific banks upon reloading my scene in my game.
when i deload a bank and then try to reload it again using LoadBank(), it isn’t loading the 2nd time, even though i am calling it with a fixed path.
public void OnSceneReload()
{
// Get the list of loaded banks
RuntimeManager.StudioSystem.getBankList(out FMOD.Studio.Bank[] loadedBanks);
// Iterate banks and unload non ignored bank paths.
for (int i = 0; i < loadedBanks.Length; i++)
{
FMOD.Studio.Bank bank = loadedBanks[i];
bank.getPath(out string path);
if (bank.isValid() && ! ignoreBankUnload.Contains(path))
{
bank.unload();
Console.Log($"Unloading bank: {path}");
}
}
}
This just gets the list of all loaded banks, and then unloads them if their path isn’t in a hashset (so i can keep some permanently loaded). Currently i have the hashset set up so it is ONLY deloading the “Enemies/Metal/Scissor” bank.
I have checked if it is loaded using the previously mentioned coroutine:
IEnumerator RecheckBank()
{
yield return null;
RuntimeManager.StudioSystem.getBankList(out var temp);
foreach (var b in temp)
{
b.getPath(out string path);
Debug.Log(path);
}
}
When i first load the scene, the bank “Enemies/Metal/Scissor” isn’t loaded, as intended. i have my fmod settings only load specific banks on initialization.
When i press B to run the check for loaded banks, it reflects this appropriately.
When i then press V to load the bank, and B to check loaded banks it properly loads the bank, and appears in the list of loaded banks.
When i then deload the bank and press V again, which should load the same bank with the exact same path, nothing happens.
I have tried checking the RESULT’s returned from the various fmod methods, but they all either give the result ERR_EVENT_NOTFOUND, or similar things which shouldn’t be the case as it works perfectly fine the first time i am loading them.