# How can I get all of banks list and event list at runtime?

**URL:** <https://qa.fmod.com/t/how-can-i-get-all-of-banks-list-and-event-list-at-runtime/20474>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [July 27, 2023, 12:26pm UTC](https://qa.fmod.com/t/how-can-i-get-all-of-banks-list-and-event-list-at-runtime/20474 "2023-07-27T12:26:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MisakaCirno](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@MisakaCirno](https://qa.fmod.com/u/MisakaCirno)\
**Post date:** [July 27, 2023, 12:26pm UTC](https://qa.fmod.com/t/how-can-i-get-all-of-banks-list-and-event-list-at-runtime/20474/1 "2023-07-27T12:26:20Z")

</div>

I am trying to dynamically load the required bank files at runtime.  
But there is a problem, how do I know which bank file to load when I have a path of the event?

I noticed in the documentation that it mentions that in the master.string.bank folder, the paths to all events are stored :  
[FMOD - Getting Events into Your Game (what building creates)](https://fmod.com/docs/2.02/studio/getting-events-into-your-game.html#what-building-creates)

But I have referred to the answers in this thread and did not succeed in getting any results, how can I solve this problem?  
[Retrieve list of events from Masters.strings bank - FMOD Studio - FMOD Forums](https://qa.fmod.com/t/retrieve-list-of-events-from-masters-strings-bank/17452/6)

My code:

```auto
        FMOD.RESULT result = FMOD.Studio.System.create(out system);
        if (result != FMOD.RESULT.OK)
        {
            Debug.Log("Load system error!");
        }

        result = system.initialize(512, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, new IntPtr(0));
        if (result != FMOD.RESULT.OK)
        {
            Debug.Log("Initialize system error!");
        }

        system.getBank("Master.strings", out Bank bank);
        var r = bank.getStringCount(out int count);
        Debug.Log($"result:{r} count:{count}");

        //log: result:ERR_INVALID_HANDLE count:0

```

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [July 28, 2023, 1:52am UTC](https://qa.fmod.com/t/how-can-i-get-all-of-banks-list-and-event-list-at-runtime/20474/2 "2023-07-28T01:52:43Z")

</div>

Hi,

The master strings bank will need to be loaded before you call `Studio.System.getBank()`. If you load your bank using one of the `loadBank` functions that belongs to `Studio.System` instead of by `FMODUnity.RuntimeManager.LoadBank()`, you won’t need to call `Studio.System.getBank()` as `loadBankFile()` et al. will return a reference to the `Bank`.

If you do end up calling `Studio.System.getBank()`, you need to preface your bank path with `"bank:/"` in a similar convention to event path names - for example, `"bank:/Master.strings"` would be the correct path in this case.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![MisakaCirno](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@MisakaCirno](https://qa.fmod.com/u/MisakaCirno)\
**Post date:** [July 28, 2023, 3:25am UTC](https://qa.fmod.com/t/how-can-i-get-all-of-banks-list-and-event-list-at-runtime/20474/3 "2023-07-28T03:25:40Z")

</div>

Thank you for your reply, I am now able to use the `getStringCount()` and `getStringInfo()` methods, but the content in the `master.strings.bank` file doesn’t seem to be what I want.

Is there any way I can get what events are stored in each bank file? Or can I only read the entire bank file to get the full information?

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [July 31, 2023, 3:24am UTC](https://qa.fmod.com/t/how-can-i-get-all-of-banks-list-and-event-list-at-runtime/20474/4 "2023-07-31T03:24:18Z")

</div>

You will need to load a bank to retrieve a list of events that belong to it - the following code snippet demonstrates doing so using `FMODUnity.RuntimeManager` and printing all events contained in the bank:

```auto
        FMODUnity.RuntimeManager.LoadBank("SFX.bank");
        FMODUnity.RuntimeManager.StudioSystem.getBank("bank:/SFX", out Bank sfxbank);
        sfxbank.getEventList(out EventDescription[] events);
        foreach (EventDescription e in events)
        {
            e.getPath(out string path);
            Debug.Log(path);
        }

```

However, it’s worth noting that the expected workflow with banks and events with FMOD is to know which events you will need ahead of time, and to sort them into bank accordingly so you know which bank(s)to load at a given moment. Is there a specific reason why you’re trying to dynamically load a bank with only knowledge of an event path?

---

<div class="post-metadata">

**Author:** ![MisakaCirno](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@MisakaCirno](https://qa.fmod.com/u/MisakaCirno)\
**Post date:** [August 1, 2023, 2:51am UTC](https://qa.fmod.com/t/how-can-i-get-all-of-banks-list-and-event-list-at-runtime/20474/5 "2023-08-01T02:51:25Z")

</div>

I am using FMOD in Unity and by default FMOD loads all .bank files.  
To save memory, I want to load only the necessary .bank files.  
And I hope that the person setting the EventPath doesn’t need to be concerned about which .bank file the Event is actually stored in.

So I would like to accomplish a method like this:

```auto
    public static void EmitEvent(string eventPath)
    {
        string bankName = FindBankNameByEventPath(eventPath);

        FMODUnity.RuntimeManager.LoadBank(bankName);

        var eventReference = RuntimeManager.PathToEventReference(eventPath);
        var eventInstance = RuntimeManager.CreateInstance(eventReference);

        var startResult = eventInstance.start();
    }

```

The key point is how to implement the `FindBankNameByEventPath()` method.

But I found another way to accomplish the purpose, I can get the information in the Editor via `EventManager.Events` and save them to a .json file. Read this .json file at runtime to find out where the event belongs in relation to the .bank file.

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [August 1, 2023, 5:33am UTC](https://qa.fmod.com/t/how-can-i-get-all-of-banks-list-and-event-list-at-runtime/20474/6 "2023-08-01T05:33:46Z")

</div>

> [@MisakaCirno](#):
>
> To save memory, I want to load only the necessary .bank files.

If you weren’t aware, banks consist of metadata (mixer and event structure, etc.) and sample data (your source audio). When loading a bank, unless you manually choose to load the sample data, only the metadata is loaded. Instead, when you create an Event Instance, FMOD will load the sample data on demand. As a result, it’s unlikely that you need to be concerned about banks taking up too much memory - I would recommend assigning your events to banks appropriately so you know which banks to load ahead of time for a given section of your Unity project.

For more information, I would recommend giving the following thread a read: [Is it possible to load a Bank from an EventInstance or EventReference?](https://qa.fmod.com/t/is-it-possible-to-load-a-bank-from-an-eventinstance-or-eventreference/20389)

As well as taking a look at the [Sample Data Loading section of the Studio API guide](https://fmod.com/docs/2.02/api/studio-guide.html#sample-data-loading).

---

<div class="post-metadata">

**Author:** ![MisakaCirno](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@MisakaCirno](https://qa.fmod.com/u/MisakaCirno)\
**Post date:** [August 1, 2023, 1:19pm UTC](https://qa.fmod.com/t/how-can-i-get-all-of-banks-list-and-event-list-at-runtime/20474/7 "2023-08-01T13:19:23Z")

</div>

I didn’t realize that FMOD automatically loads the two parts separately, thanks for the important information!
