Load Banks from PersistentDataPath on mobile


I’m trying to load a bank from my server, but can’t make it to work on mobile, only desktop.

The original path for Master.bank and Master.Strings.bank is Assets/StreamingAssets/.

I setup integration as Single Platform Build - Import Type: Streaming Assets.

I tried Asset Bundle, but the path will never be the correct one.

When I add Application.persistentDataPath to the bank path, the full real path becomes Assets/StreamingAssets/ + Application.persistentDataPath.

So I’m never able to load from persistentDataPath.
Is there a workaround or something I’m missing?

Here’s the code:

UnityWebRequest MyRequest;
IEnumerator DownloadMusic01()
    MyRequest = new UnityWebRequest("https://myserver.com/music1.bank", UnityWebRequest.kHttpVerbGET);

path = Path.Combine(System.IO.Path.Combine(Application.streamingAssetsPath), "music1.bank");
MyRequest.downloadHandler = new DownloadHandlerFile(path);
yield return MyRequest.SendWebRequest();

if (MyRequest.isHttpError)
    Debug.Log("File successfully downloaded and saved to " + path);

if (MyRequest.downloadHandler.isDone)
    bankPathMusic1 = path;

    FMOD.Studio.System bankload;
    FMOD.Studio.System.create(out bankload);
    var loadingResult = bankload.loadBankFile("music1.bank", FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out loadedBank);


    bankPathMusic1 = "music1.bank";

    FMODUnity.RuntimeManager.LoadBank(bankPathMusic1, true);

    PlayerStateEvent = "event:/Mix1";
    playerState = FMODUnity.RuntimeManager.CreateInstance(PlayerStateEvent);


It appears that you are trying to load the same bank twice, using FMOD.Studio.System.loadBankFile and FMODUnity.RuntimeManager.LoadBank, but you should only need to load it once. Also, FMOD.Studio.System.create creates a brand new system outside of the one used by the RuntimeManager.

You can access the RuntimeManagers system by doing something like this:

FMOD.Studio.System studioSystem;
studioSystem = FMODUnity.RuntimeManager.StudioSystem;
var loadingResult = studioSystem.loadBankFile("music1.bank", FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out loadedBank);

If the bank is located in the streamingAssets folder then you should just be able to pass in the bank name to RuntimeManager.LoadBank but if it is in a different directory, that FMOD doesn’t know about, you will have to load it manually using FMOD.Studio.System.loadBankFile.

Using addressables, you have the option of loading the asset yourself or passing it to the RuntimeManager and having it load the asset before loading the bank, see FMOD - User Guide (assetbundles addressables).

Thanks, Cameron!!

Now it’s working on both Desktop and Android.
Couldn’t test in IPhone because of a build error inside XCode that is supposed to be fixed soon.

Thanks a ton for your help!!

1 Like