SubAssets not loading correctly through ResourceLocationMap

I’ve only started really digging into addressables so it’s very possible I’m just not seeing the appropriate path here but we’ve got a need in our project to process over assets and store some internal data. I’m trying to use addressables to do this by locating all assets with a label and loading them. This works great for main assets but for subassets it seems to fall apart. There are two instances I’ve noticed (so far) that aren’t working the way I thought they would. The first (and simpler) is two sub assets of the same type, it only locates and the loads the first sub asset. This scenario is supplied below is more detail. The second scenario is two sub assets of different types but share a parent type. It locates both but when loading it results in the first asset twice. I’ll dig into this scenario in a follow up post if the first one is resolved.

For the first scenario here is the asset I’m using to test with. The type is in the parenthesis.

6688342--767008--upload_2021-1-4_19-5-26.png

It has been marked as addressable and given the label “myLabel”

The two scriptable objects types are just simple stubs. Below is the code I’m using to try to load the assets.

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceLocations;

public class TestAddressables : MonoBehaviour
{
   private void Awake()
   {
      AsyncOperationHandle<IResourceLocator> op = Addressables.InitializeAsync();

      op.Completed += x =>
      {
         if (x.Result.Locate("myLabel", typeof(TestObjectB), out IList<IResourceLocation> locations))
         {
            // Only one location is found? I think I expect two?

            AsyncOperationHandle<IList<TestObjectB>> op2 = Addressables.LoadAssetsAsync<TestObjectB>(
               locations,
               null);

            op2.Completed += y =>
            {
               // Only the SubAssetA is actually loaded (or at least loaded into this list)! Expecting two?
            };
         }
      };
   }
}

I’m on Addressables 1.8.5 but I have tested with 1.16.15 and the issue is there as well.
Unity Version: 2020.1.0613

Thanks for any help!

The solution is to load a list of the objects.

 AsyncOperationHandle<IList<IList<TestObjectB>>> op2 = Addressables.LoadAssetsAsync<IList<TestObjectB>>(
               locations,
               null);

This is a little awkward when loading a parent class and there are multiple children of different types that inherit from it (you’ll get the objects back multiple times) but is workaroundable easily enough

EDIT: If the asset in question can be a main asset OR sub asset then this won’t catch both and will need to do a list variety and a non-list variety.

That’s very helpful! Thank you!