Addressables: Load Banks and play event on the same frame

Hello, forum!

I’m using FMOD plugin with Asset Bundle import type.

I’ve implemented some manager, which loads banks in Awake as was described in https://www.fmod.com/docs/2.00/unity/examples-async-loading.htm. I added StudioEventEmitter to the scene with particular sound event.
Both manager and emitter objects are located on the same scene. Manager object has Script execution order below than StudioEventEmitter to be sure that loading completes before event will start to play.

Figured out that event doesn’t fire causing error (EventNotFoundException). That was fixed only after putting delay something like this in the derived class by StudioEventEmitter :

protected override void Start()
{
	StartCoroutine(DelayedStart());
}

private IEnumerator DelayedStart()
{
	yield return new WaitForEndOfFrame();
	base.Start();
}

So, my question is how to fire events in the normal way without these delay stuff? As I understood between loading and playing occurs some initialization stuff on FMOD Studio’s side. Could you please specify how to force that kind initialization?
Thanks in advance!

Hi,

What version of the FMOD integration are you using?

Loading the banks is not an instant operation. An option may be to utilize a loading scene outlined here: Unity Integration | Scripting Examples: Asynchronous Loading.

Hope this helps!

Hi, Connor!

Thanks for you answer! I’m using 2.02 version of Unity integration.

You’ve answered correctly that loading is not an instant operation. I saw your provided example of asynchronous loading but my case a little straightforward:

[ExecutionOrder(-221)] (customly set in player settings)
BankLoader.cs:

#if UNITY_EDITOR
private void Awake()
{
	LoadAllBanks();
}
#endif

private void LoadAllBanks()
{
    FMODUnity.RuntimeManager.LoadBank(masterBank);
    FMODUnity.RuntimeManager.LoadBank(masterStringBank);

    foreach (AssetReference bankReference in banksToPreload)
    {
        FMODUnity.RuntimeManager.LoadBank(bankReference, true);
    }
}

After completing execution of LoadAllBanks() I expected using StudioEventEmitter’s “On Object Start” event right after load was completed because load by itself was performed synchronously.
So, StudioEventEmitter is able to work normally if I make inherited class and calling event “On Object Start” (see base.Start()) only after any script execution was completed:

[ExecutionOrder(-220)] (set by plugin)
CustomStudioEventEmitter.cs:

protected override void Start()
{
	StartCoroutine(DelayedStart());
}

private IEnumerator DelayedStart()
{
	yield return new WaitForEndOfFrame();
	base.Start();
}

Hi,

Thank you for the code,

I think the current solution is your best option. As for the execution order that seems like a Unity issue. Apologies I cannot assist further.