My apologies I missed that, to use Addressables
follow this example:
-
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.
-
Import the
Addressable Package
from the UnityAsset Manager Window
under Unity Toolbar → Window → Package Manager → Unity Registry → Addressables.
- Assign the FMOD
Text Assets
toAddressables
, you can do this by selecting them in yourProject Directoy
and ticking theAddressable
tick box
- The
Addressables
will want to be loaded into memory `Asyn - Now the
Addressables
are ready to be loaded into memory. Create a new script namedLoadAllBanks
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());
}
}
-
In the Inspector window of an object with your script, add the
banks
you wish to load
-
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 thebanks
then a populatedscene
to play them in. So in your UnityBuild Settings
you will want to have something like this:
In theEmptyScene
is our object that loads ourbanks
, then we transition to theMusicScene
where we will hear our events. -
Make sure to start the project in the
EmptyScenetoLoadBanks
, now all the assignedbanks
should be loaded
Sorry about the confusion, I hope this helps!