RuntimeManager.LoadBank fail

in unity 2021.3.16f1

BankLoadException: [FMOD] Could not load bank ‘J:/FMODProject/Genesis/Build/Desktop/SFX.bank’ : ERR_INVALID_HANDLE : An invalid object handle was used.

int maxchannels = 128;
RuntimeManager.StudioSystem.initialize(maxchannels, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
TextAsset bankAsset = ResMgr.Instance.LoadSync<TextAsset>("Assets/Res/Sound/Fmod/SFX.bytes", out var outAREx);
RuntimeManager.LoadBank(bankAsset);

Hi,

What version of FMOD are you using? I will link to our documentation on the subject under Unity Integration | User Guide - Asset Bundles and Addressables.

This indicates that there might be an issue with the TextAsset you are passing into the LoadBank() function.
Could you try the following code:

Load Bank Assets
void Awake()
{
	var assetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "banks"));
	if (assetBundle == null)
	{
		Debug.LogError("Failed to load AssetBundle!");
		return;
	}

	foreach (var name in assetBundle.GetAllAssetNames())
	{
		FMODUnity.RuntimeManager.LoadBank(assetBundle.LoadAsset<TextAsset>(name));
	}

	Debug.Log("Succesfully loaded assetBundle");

	assetBundle.Unload(false);
}

Using that make sure the banks .bytes file is marked as so:
image
Hope this helps!

int maxchannels = 128;
 RuntimeManager.StudioSystem.initialize(maxchannels, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
TextAsset bankAsset = ResMgr.Instance.LoadSync<TextAsset>(Common.RES_ROOT_PATH + "Sound/Fmod/SFX.bytes", out var outAREx);    //bankAsset.text is bank stub:SFX
RuntimeManager.LoadBank(bankAsset);

I feel something wrong

Hi,

Could you elaborate on the issue? Are you still getting the same error as the original post?

I still getting the same error as the original post
help

In the documentation I linked in the previous post:

It has information about the bank stubs, in summary: “At build time, each asset is filled with the actual bank data for the build platform, so it can be included in the build. When the build finishes, each asset is reset to stub data.”

The stub will get filled with data at build time thus causing the difference in size when viewed in the asset browser.

Would it be possible to see the full script you are using to load in the bank stubs?

I use Yooasset to package to generate bundle files

I found that the following code is not called, why?

Hi,

This is an initializer function and is called by the class when building the project.

Apologies, I missed this before:

int maxchannels = 128;
RuntimeManager.StudioSystem.initialize(maxchannels, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero); 
TextAsset bankAsset = ResMgr.Instance.LoadSync<TextAsset>(Common.RES_ROOT_PATH + "Sound/Fmod/SFX.bytes", out var outAREx);    //bankAsset.text is bank stub:SFX
RuntimeManager.LoadBank(bankAsset);

A couple of things to change here:

  1. Could you please elaborate on why you are initializing an FMOD system here? There should already be one created by the integration.
  2. The line RuntimeManager.LoadBank(bankAsset); may be trying to load the TextAsset before it is ready. I would suggest creating a coroutine using while(RuntimeManager.AnyBankLoading()) yield return; to make sure that all banks have loaded before trying to continue.

Again, could I suggest trying to use the code I provided above:

Hope this helps!

Thanks for your reply, I will check my code and don’t initialize manually anymore.

But before that, there is already a problem with generating the Bundle package, and I need to find a way to solve the problem of generating the Bundle package.

Because the function registered by Fmod has not been called, I manually call CopyToStreamingAssets and UpdateBankStubAssets, but the size of the generated bundle file is still wrong

Hi,

Would it be possible to get a stripped-out Unity project and the FMOD Studio project uploaded to your profile? You will need to register a project with us to do so. This will allow me to test the issue on my side where I can step through the code.