# Loading and unloading Banks via code

**URL:** <https://qa.fmod.com/t/loading-and-unloading-banks-via-code/22547>\
**Category:** Unity\
**Created:** [January 26, 2025, 8:44pm UTC](https://qa.fmod.com/t/loading-and-unloading-banks-via-code/22547 "2025-01-26T20:44:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntvilStudios](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@AntvilStudios](https://qa.fmod.com/u/AntvilStudios)\
**Post date:** [January 26, 2025, 8:44pm UTC](https://qa.fmod.com/t/loading-and-unloading-banks-via-code/22547/1 "2025-01-26T20:44:21Z")

</div>

Hi, im trying to figure out how to load and unload banks via code and the documentation is a bit unclear for me.

I´m using the command LoadBank , which demands the bankName + boolean parameter. IE:

```auto
private Bank loadBank;
RuntimeManager.LoadBank(loadBank, true);
FMOD.RESULT result = RuntimeManager.StudioSystem.getBank(loadBank, out loadedBank);

```

It doesn´t work and I´m a bit clueless. So my questions are:

1. When naming the banks to load should i use a string var or a bank var (for example public Bank loadBank).
2. Should i add “.bank” to the name of the bank to load?.
3. I cannot get the path of any bank (i use getPath).
4. If i wanted to save the name of a loaded bank in a public variable , what sould i use?  
Sorry for this mess and thank you for your help 🙂

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [January 27, 2025, 10:51pm UTC](https://qa.fmod.com/t/loading-and-unloading-banks-via-code/22547/2 "2025-01-27T22:51:00Z")

</div>

Hi,

We have a `StudioBankLoader.cs` script which may be a useful reference.

There are three options for variables to pass to [LoadBank()](https://fmod.com/docs/2.02/unity/api-runtimemanager.html#loadbank)

- `string`
- `assetReference`
- `asset`

I would suggest using a `string` with the `FMODUnity.BankRef` attribute:

```auto
[FMODUnity.BankRef]
public string loadBank;

// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
    FMODUnity.RuntimeManager.LoadBank(loadBank, true);
}

```

[Unity Integration | Scripting API Reference - Banks](https://fmod.com/docs/2.02/unity/api.html#banks).

> [@AntvilStudios](#):
>
> Should i add “.bank” to the name of the bank to load?.

Using the `FMODUnity.BankRef` will take care of this for you.

> [@AntvilStudios](#):
>
> I cannot get the path of any bank (i use getPath).

Could I get a code snippet where you are trying to retrieve the path?

> [@AntvilStudios](#):
>
> If i wanted to save the name of a loaded bank in a public variable , what sould i use?

Refer to answer above.

No worries! Please let me know if there is anything else I can assist with!

---

<div class="post-metadata">

**Author:** ![AntvilStudios](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@AntvilStudios](https://qa.fmod.com/u/AntvilStudios)\
**Post date:** [January 28, 2025, 8:56pm UTC](https://qa.fmod.com/t/loading-and-unloading-banks-via-code/22547/3 "2025-01-28T20:56:26Z")

</div>

Thank you for your fast reply. BankRef worked perfectly!!. Thank you very much.

Regarding the getPath method. This is the snippet.

```Bank
            FMOD.RESULT result = RuntimeManager.StudioSystem.getBank(bankName, out bank);
            FMOD.RESULT path = bank.getPath(out bankPath);
Debug.Log("Path is " + bankPath");

```

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [January 28, 2025, 11:10pm UTC](https://qa.fmod.com/t/loading-and-unloading-banks-via-code/22547/4 "2025-01-28T23:10:49Z")

</div>

No worries, good to hear we got is solved!

Thank you for the code, that looks all good. Is it now working?

---

<div class="post-metadata">

**Author:** ![AntvilStudios](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@AntvilStudios](https://qa.fmod.com/u/AntvilStudios)\
**Post date:** [February 5, 2025, 11:18am UTC](https://qa.fmod.com/t/loading-and-unloading-banks-via-code/22547/5 "2025-02-05T11:18:55Z")

</div>

Yes, it works!!. Thank you very much for the help!!
