Unity iOS Events from banks not found

Hey all,

We are building an iOS app using Unity with FMOD integration. Currently, we are able to load all banks into the project both in the Unity Editor and the iOS device. However, once these banks are loaded, they seem to have no events associated with them. The odd thing is that within the Unity Editor, everything works as expected. The banks load, and we are able to loop through the events within those banks to create buttons for the user to interact with, even play. However, once we build to an iOS device, when we call getEventList on the bank we receive the RESULT error FMOD_ERR_INVALID_HANDLE.

Within the Unity Editor our FMOD Settings are set to Initialization: Load Banks = None

Here is our Code Snippet:
IEnumerator Start()
FMOD.Studio.Bank masterbank;
FMOD.Studio.Bank masterbankstrings;
RuntimeManager.StudioSystem.loadBankFile(“Assets/StreamingAssets/Master.bank”, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out masterbank);
RuntimeManager.StudioSystem.loadBankFile(“Assets/StreamingAssets/Master.strings.bank”, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out masterbankstrings);
Banks = Settings.Instance.Banks;

    bankArray = new FMOD.Studio.Bank[Banks.Count];
    int counter = 0;

    foreach (string bank in Banks)
        RuntimeManager.StudioSystem.loadBankFile("Assets/StreamingAssets/" + Banks[counter] + ".bank", FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bankArray[counter]);
        categories.Add(bank, new List<CategoryItem>());

    while (RuntimeManager.AnyBankLoading())
        yield return null;

    for(int ii = 0; ii < bankArray.Length; ii++)

        FMOD.Studio.EventDescription[] eventList;

        RESULT result = bankArray[ii].getEventList(out eventList);
        if (result != RESULT.OK)
            yield break;

        while(eventList.Length == 0)
            print("Always yeilding");
            yield return null;
        for(int jj = 0; jj < eventList.Length; jj++)
            CategoryItem item = new CategoryItem();
            FMOD.RESULT r = eventList[jj].createInstance(out item.eventInstance);
            if(r == FMOD.RESULT.OK)
                RESULT FUFMOD = item.eventInstance.getDescription(out item.description);
                if (FUFMOD == RESULT.OK)
                    print("DESC OK");
                int length;
                RESULT lengthR = item.description.getLength(out length);
                if (lengthR == RESULT.OK)
                    print("Lengt OK");
                    item.lengthOfClip = (float)length / 1000f;
                RESULT re = item.description.getPath(out item.eventPath);
                if(re == RESULT.OK)
                    print("NAME OK: " + item.eventPath);
                    int i = item.eventPath.LastIndexOf('/');
                    item.name = item.eventPath.Substring(i + 1, item.eventPath.Length - 1 - i);
                    print(item.name + " | " + item.lengthOfClip);
                } else
                //if(item.name != null && item.name != "")
                //    print(item.name);
                //    categories[Banks[ii]].Add(item);
                //    //checker = categories[Banks[ii]].ToArray();
                //} else
                //    print("name is null");
            } else
                print("Events Not Loaded");

Any help on why these events may not load on iOS where they do load in the Editor would be VERY much appreciated. Also, I’m more than willing to provide any additional information.

The issue will be the bank path in the loadBankFile, when referring to the StreamingAssets folder across multiple platforms it is best to use Application.streamingAssetsPath. This provides the platform specific path.

Hey Cameron,

Thanks for getting back to me. That tracks with what I’ve done currently in my project, which is to just rip out FMOD and use the files directly in the streamingAssets folder. Obviously, we’d like to use FMOD. I think you’re telling me this line of code:

RuntimeManager.StudioSystem.loadBankFile(“Assets/StreamingAssets/” + Banks[counter] + “.bank”, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bankArray[counter]);

needs to be changed to:
RuntimeManager.StudioSystem.loadBankFile(“file:///” + Application.streamingAssetsPath + Banks[counter] + “.bank”, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bankArray[counter]);

That track with what you’re saying?


For iOS, we will just use:

Application.streamingAssetsPath + '/' + bankName.bank

You can see what we do for different platforms in RuntimeUtils.GetBankPath.