I am trying to load my banks using Addressables but not getting anywhere. The documentation isn’t quite clear on this, but I am trying to load what I think you guys call stub files? It’s not clear to me how these text files point to the .bank files that I think I should be loading.
When I do I keep getting this error:
[FMOD] assert : assertion: 'mRiffChunk.mType == ChunkType_Riff && mRiffChunk.mID == id' failed
Failed to load Master.bank with error: ERR_FORMAT
Down below is a copy of my code.
public class AudioMixer : MonoBehaviour
{
#region Fields
public static AudioMixer Instance => _instance;
private static AudioMixer _instance;
private const string MasterBankKey = "FMODBanks/Master.bytes";
public AssetReference MasterBank;
public AssetReference MasterStringBank;
public List<AssetReference> Banks;
public bool PreloadSamples;
#endregion
#region Methods
private void OnEnable()
{
Load();
}
private void Awake()
{
if (_instance == null)
{
_instance = this;
InitializeFMODSystem();
// StartCoroutine(LoadMasterBank());
}
else
{
Debug.LogWarning("AudioMixer instance already exists!");
Destroy(this);
}
}
private void Start()
{
RuntimeUtils.EnforceLibraryOrder();
}
private void InitializeFMODSystem()
{
FMOD.Studio.System system = RuntimeManager.StudioSystem;
if (!system.isValid())
{
Debug.LogError("Cannot get FMOD.Studio.System instance!");
return;
}
}
public void Load()
{
foreach (var bankRef in Banks)
{
try
{
RuntimeManager.LoadBank(bankRef, PreloadSamples);
}
catch (BankLoadException e)
{
RuntimeUtils.DebugLogException(e);
}
}
RuntimeManager.WaitForAllSampleLoading();
}
private IEnumerator LoadMasterBank()
{
AsyncOperationHandle<TextAsset> handle = MasterBank.LoadAssetAsync<TextAsset>();
yield return handle;
if (handle.Status == AsyncOperationStatus.Succeeded)
{
var bankTextAsset = handle.Result;
Debug.Log("Loaded TextAsset for Master.bank with size: " + bankTextAsset.bytes.Length);
FMOD.RESULT result = RuntimeManager.StudioSystem.loadBankMemory(bankTextAsset.bytes, LOAD_BANK_FLAGS.NORMAL, out Bank bank);
if (result == FMOD.RESULT.OK)
{
Debug.Log("Successfully loaded Master.bank");
}
else
{
Debug.LogError("Failed to load Master.bank with error: " + result);
}
// Addressables automatically handle releasing the asset
}
else
{
Debug.LogError("Failed to load Master.bank addressable");
}
}
I would love to see how someone setup their project and an example on how they load banks using Addressables.