In the case of Android game development, the .bank
file that accompanies the .apk
file can no longer be in the same path as the .bank
file for subsequent updates, so how do I solve this problem?
There seems to be no way to set multiple paths as search paths in FMODStudioSettings
, does this mean that I should find these new .bank
files myself and load them myself using the LoadBank()
method?
My current approach is to extend my own method based on the LoadBank
method in RuntimeManager
to load the .bank
file by providing a full path to the .bank
file.
After testing it all seems to work fine, other than that is there any better way?
Hi,
I’m happy to see you’ve managed to find a solution. That said, since you recently asked about AssetBundles, are you using StreamingAssets or AssetBundles as your import type? With AssetBundles, while FMOD for Unity does build with the original banks, the user is responsible for loading new banks/bank versions at runtime, which need to be in the TextAsset
format and loaded with the relevant overload for RuntimeManager.LoadBank()
.
1 Like
Thank you for your reply.
After our discussion, we finalized using StreamingAssets to store banks.
I set Load Banks
in FMODStudioSettings
to None
, and then proceeded to load any specified bank file the same way I would with AssetBundles.
My modified method looks like this:
public static void LoadBankByFilePath(string bankPath, string bankName, bool loadSamples = false)
{
string bankId = bankName;
if (Instance.loadedBanks.ContainsKey(bankId))
{
ReferenceLoadedBank(bankId, loadSamples);
}
else
{
Instance.loadingBanksRef++;
#if UNITY_ANDROID && !UNITY_EDITOR
if (Settings.Instance.AndroidUseOBB)
{
Instance.StartCoroutine(Instance.loadFromWeb(bankPath, bankName, loadSamples));
}
else
#elif UNITY_WEBGL && !UNITY_EDITOR
if (true)
{
Instance.StartCoroutine(Instance.loadFromWeb(bankPath, bankName, loadSamples));
}
else
#endif // (UNITY_ANDROID || UNITY_WEBGL) && !UNITY_EDITOR
{
LoadedBank loadedBank = new LoadedBank();
FMOD.RESULT loadResult = Instance.studioSystem.loadBankFile(bankPath, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out loadedBank.Bank);
Instance.RegisterLoadedBank(loadedBank, bankPath, bankId, loadSamples, loadResult);
Instance.loadingBanksRef--;
}
}
}
One interesting thing I realized during this process is that it doesn’t matter what the name of the .bank
file is, even if you change it to any name, it will still work fine when loaded.
The same is true for bankId
, but you need to make sure that the bankId
is unique for each .bank
file, and you need to make sure that you can map the .bank
file to the bankId
.Otherwise you won’t be able to unload them accurately.
1 Like