Loading multiple assets of a type using tags

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

ANSWER:

You cannot pass a string as argument for Addressables.LoadAssetsAsync, it needs to be a list of strings with the keys, apparently. That way my code above worked.

However the documentation examples clearly use “objectKey” as reference like here
https://docs.unity3d.com/Packages/com.unity.addressables@1.13/manual/LoadingAddressableAssets.html#addressablesloadassetsasync-1

Unity gives people this example

IEnumerator LoadAllAssetsByKey()
{
    //Will load all objects that match the given key. 
    //If this key is an Addressable label, it will load all assets marked with that label
    AsyncOperationHandle<IList<GameObject>> loadWithSingleKeyHandle = Addressables.LoadAssetsAsync<GameObject>("objectKey", obj =>

Which DOES NOT work. So the methods arguments provided are wrong, wrong signatures.

How annoying.