Can not load bank(.bytes) In Resources Files

My apologies I missed that, to use Addressables follow this example:

  1. We need to ensure we have defined UNITY_ADDRESSABLES_EXIST in the player settings. This can be found under Unity Toolbar → Edit → Project Settings → Player → Other Settings → Script Compilation. You may get some errors in the console but that is fine, they will be solved in the next step.

  2. Import the Addressable Package from the Unity Asset Manager Window under Unity Toolbar → Window → Package Manager → Unity Registry → Addressables.

Package Manager

  1. Assign the FMOD Text Assets to Addressables, you can do this by selecting them in your Project Directoy and ticking the Addressable tick box
  2. The Addressables will want to be loaded into memory `Asyn
  3. Now the Addressables are ready to be loaded into memory. Create a new script named LoadAllBanks and then copy the following example into that script. You can change the name if you like.
LoadAllBanks class
	Using UnityEngine; 
	using System;
	using System.Collections.Generic;
	using UnityEngine.AddressableAssets;
	using System.Collections;
	using UnityEngine.SceneManagement;
	
	public class LoadAllBanks : MonoBehaviour
	{
	    public List<AssetReference> Banks = new List<AssetReference>();
	    public string Scene;
	
	    private static int numberOfCompletedCallbacks;
	
	    void Awake()
	    {
	        StartCoroutine(LoadBanksAsync());
	    }
	
	    private Action Callback = () =>
	    {
	        numberOfCompletedCallbacks++;
	    };
	
	    IEnumerator LoadBanksAsync()
	    {
	
	        Banks.ForEach(b => FMODUnity.RuntimeManager.LoadBank(b, true, Callback));
	
	        while (numberOfCompletedCallbacks < Banks.Count)
	            yield return null;
	
	        while (FMODUnity.RuntimeManager.AnySampleDataLoading())
	            yield return null;
	
	        AsyncOperation async = SceneManager.LoadSceneAsync(Scene);
	
	        while (!async.isDone)
	        {
	            yield return null;
	        }
	
	        Banks.ForEach(b => b.ReleaseAsset());
	    }
	}
  1. In the Inspector window of an object with your script, add the banks you wish to load
    image

  2. Loading Unity assets are an Asynchronous operation, further explanation can be found in Unity | Getting started with Addressable Assets, so we will need an empty scene to load the banks then a populated scene to play them in. So in your Unity Build Settings you will want to have something like this:
    image
    In the EmptyScene is our object that loads our banks, then we transition to the MusicScene where we will hear our events.

  3. Make sure to start the project in the EmptyScenetoLoadBanks, now all the assigned banks should be loaded

Sorry about the confusion, I hope this helps!

1 Like