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.
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!