How to obtain bankName from EventReference GUID?

my project update to the Version 2.02.
I notice that EventRef is obsolete.So I used EventReference.
What I’m thinking about right now is using assetBundle. But I can’t get the bankname through EventReference. So I can’t load the corresponding assetBundle.
Please tell me how to get bankame via EventReference GUID. Thank you very much.

Hi,

Unfortunately, there isn’t a way to retrieve a bank name directly from an EventReference. However, you could implement a Dictionary containing all the banks and their events yourself.

You will want to use Studio::System:getBankList, which you supply with an array of FMOD.Sudio.Banks, calling this on the currently initialized Studio System. Whether that is one you have initialized or if it is the FMOD.RunTimemanager.StudioSystem.

Once you have the array of banks you will want to loop through the array retrieving all the events attached to each bank using Studio::System::getEvetList. Supplying an array of FMOD.Studio.EventDescriptions this time.

Now loop through the EventDescription array adding each event and bank to the Dictionary, using the event as the ‘key’ as the bank ‘value’.

Now you will have a Dictionary full of the banks and you can use the events in that Dictionary for their corresponding bank. You can decide how you want to implement accessing this Dictionary throughout your code.

Hope this helps!

Hi Connor, thanks for the response.

I have tried this method. But not the desired effect.Studio::System:getBankList would get only Banks has been loaded. Banks that have not been loaded do not exist in this list.

Before creating EventInstance, you first load the Bank.

However, I am currently unable to load the bank from the Serializable EventReference, Because I can’t get the BankName from EventReference.

Above is my code, but it cannot play at present because bank cannot load.I’m now thinking of moving EventReference.Path out of EventReference UNITY_EDITOR Define.This way I can get BankName by EventReference.Path and load Bank. FMOD also works fine.

I still hope there is a better solution. Because I saw the official guide creator to use FMOD.GUID.

Hi,

Sorry to hear that didn’t help

Could you please link to which official guide you are using?

There is an easier way to play from an EventReference that doesn’t require a reference to the events bank. It is explained in Unity Integration Scripting Examples | Basic.

Hope this helps!

Hi Connor,

Here is the documentation I looked at. FMOD for Unity

I also want to use this method to create an EventInstance directly to play the audio file. But the audio data is in the Bank. I have to load the Bank first. If I create directly I get a NullReferenceException.
image

The Import Type I’m currently using is AssetBundle. Below is my AssetBundle.
image

Before calling FMODUnity.RuntimeManager.CreateInstance(EventReference), I have to get the BankName, load the AssetBundle file, then load the Bank, and finally I can CreateInstance.

The current problem is that I can’t get the corresponding BankName through the EventReference on the script, so I can’t load the Bank.

The current problem is that the corresponding BankName cannot be obtained through the EventReference on the script, so the corresponding AssetBundle cannot be loaded. After loading the AssetBundle, I need to load the Bank.

thanks again for your response.

Hi,

The import type will change a lot of functionality. When working with the Asset Bundle
A solution may be getting the bank names through an Editor Window using the FMODUnity.BankRef which will allow you to choose the bank you wish to load from a list.

Keep in mind that the Master.bank and Master.strings.bank must be loaded for Events to be triggered properly. Without the Master.bank you will not be able to call events at all, and without the Master.strings.bank you will not be able to retrieve events using their paths.

Firstly the easiest way to get a list of the currently loadable banks is using:

[FMODUnity.BankRef] public string _bank;

Although to allow you to load multiple banks which will be required it is a good idea to create a list instead like this:

[FMODUnity.BankRef] public List<string> _banksToBeLoaded = new List<string>();

This will allow you to select multiple banks to be loaded in Editor like this:

image

Then you can loop through the list loading each bank like this:

for (int i = 0; i < _banksToBeLoaded.Count; i++)
{
         FMODUnity.RuntimeManager.LoadBank(_banksToBeLoaded[i]); 
}

Allowing all the banks in the list to be loaded!

This way you wont need to get the name of the bank off the EventReference

Hope this helps!

Hi Connor,

This solution can’t solve my problem, I want to load the bank only when I need it.

For example, I only load the Music1 Bank in the first interface of the game, and I only load the Music2 Bank in the second game. it’s so flexible. But this idea is currently impossible. I thought of the solution.

  1. I can only achieve this effect by saving the associated data of Event and Bank by myself.
[SerializeField]
public List<FMOD.GUID> _eventGuids = new List<FMOD.GUID>();
[SerializeField]
public List<string> _bankNames = new List<string>();

//key : eventGuid  | value : bankName
private Dictionary<FMOD.GUID, string> _eventToBankName = new Dictionary<FMOD.GUID, string>();

private void Awake()
{
       for (int i = 0; i < _eventGuids.Count; i++)
       {
 	       _eventToBankName.Add(_eventGuids[i], _bankNames[i]);
       }
	_eventGuids.Clear();
	_bankNames.Clear();
	_eventGuids = null;
 	_bankNames = null;
}
  1. Move Path out of UNITY_EDITOR Define.
    image

I am currently using the second solution. I still want more flexibility and compliance. Looking forward to better solutions

Thank you for your help.

Hi,

Just to clarify, you are using the AssetBundle import method so that you only load banks in when you require them. You want to be able to find the name of a bank from an event so it can be loaded when desired, without having to reference it from the Unity Editor Window?

Hoping to avoid any other confusion.

Within the Unity integration banks and events have a one-way relationship. banks know all the events that they encapsulate which can be read once they are loaded into memory. events do not know which bank they belong too, as they are not normally used to load in banks. You are asking the event for information it does not know.

The event path you show is not a reference to the bank it is encapsulated by but rather the events location in the FMOD Studio project, this is explained under GUIDS and Paths.

I apologize for any confusion.

Hi Connor,

Thanks again for the explanation, it deepened my understanding of the FMOD System.

Yes, the bank knows all the events it encapsulates, but the events have no way of knowing which bank they are.

But my current thinking is that the bank is only loaded when I need it, so I have to know which bank the event belongs to. I’m sorry this deviates from FMOD’s design, but this is the functionality I need at the moment.

In the 2.00.08 version I used before, because I used Path as the playback credentials, I could easily get the bank corresponding to the event, but in the latest version, I can only make some changes, as I replied above , because using FMOD.GUID does not satisfy my current thinking.

My only thought at the moment is that in the near future, FMOD uses a single FMOD.GUID credential to eliminate the use of Path, so it will be very inconvenient to implement my idea.

Thanks again for your reply and help, hope there is a better solution.

Hi,

Thank you for clarifying I think we are on the same page now.
Looking over things I believe the best situation for you right now is your Dictionary that you have set up.
Currently, we are not looking at implementing the functionality you want. But, I will pass it on to the Dev team to investigate.

I apologize I couldn’t help further

Hi Connor,

Thanks for your continued reply and pass on to the development team.

I’ll keep watching and hope for better news in the future.

I wish FMOD better and better.

1 Like

Hi guys, I am having trouble doing my UI menu sounds with a button click because of this EventRef is obsolete. how can I have click sounds and hover sounds on my menu with FMOD?

Hi Connor, I am having trouble doing my UI menu sounds with a button click because of this EventRef is obsolete. how can I have click sounds and hover sounds on my menu with FMOD? thank you!!!

May I see your full script, trying to make a UI menu with FMOD click and hover sound

Hi,

What version of FMOD and Unity are you using?