Issue
How on Earth addressable work? I have tried to load a single asset which worked then obviously that is not convenient for my use case so I tried to load various at the same time and get an array with them, but it does not find them.
- I had created a new group in Addressables (also tried with default)
- I had tagged the two only assets that I have there currently as “weapons”)
- I have used Addressables.MergeMode.None as well as Addressables.MergeMode.Union.
- I am able to use LoadAssetAsync passing the asset name, but no way to load multiple assets using labels because LoadAssetsAsync says the key is not found no matter what I put.
Current code which should work
private async void LoadAssets()
{
AsyncOperationHandle<IList<WeaponScriptableObject>> handle = Addressables.LoadAssetsAsync<WeaponScriptableObject>("weapons", null, Addressables.MergeMode.None);
await handle.Task;
if (handle.Status == AsyncOperationStatus.Succeeded)
{
WeaponScriptableObject[] weapons = handle.Result.ToArray();
foreach (WeaponScriptableObject weapon in weapons)
{
Debug.Log($"(Weapn has been loaded via dataloader {weapon.weaponName}");
}
}
}
The Unity docs on the matter are rather impossible to follow for new comers. The examples are terrible and overcomplicated so ended up lost. If someone can help on this matter or throw some light on what am I doing wrong that would be appreciated.
My goal
Have a list of ScriptableObjects “indexed” as Addressable Objects tagged with whatever label, and then I want to loop through that list of assets in the Addressable Objects Group and save all the returned ScriptableObjects as JSON into disk at an arbitrary location.
Thanks in advance