Update: This was a thread problem:
I am having a hard time getting the labels to work with Addressables. I think I have a misunderstanding of what should be happening. If I use the “address” directly it works fine:
string prefab = "Assets/MyPrefab.prefab";
Addressables.InstantiateAsync(prefab , position, Quaternion.identity, this.transform).Completed += InstantiateTile_Completed;
Likewise, if I use a label with InstantiateAsync, it works.
string label = "1010";
Addressables.InstantiateAsync(label, position, Quaternion.identity, this.transform).Completed += InstantiateTile_Completed;
Now, my understanding was that Addressables.LoadResourceLocationsAsync would provide me a list of “address” that I can then pass into InstantiateAsync. So, under the constraint that I only have one prefab / addressable with the label “1010” the following should be equivalent:
List<string> labels = new List<string>();
labels.Add("1010");
var handle = Addressables.LoadResourceLocationsAsync(labels.ToArray(), Addressables.MergeMode.UseFirst);
handle.Task.Wait(); // hangs
var go = handle.Result[0];
Addressables.InstantiateAsync(go, position, Quaternion.identity, this.transform).Completed += InstantiateTile_Completed;
But that hangs and never returns.
Update: This was a misunderstanding of the Aync stuff. Not sure why, but changing to the following works:
private async Task LoadAddresses()
{
possibleAddressableAssets = await Addressables.LoadResourceLocationsAsync(addressableLabels, Addressables.MergeMode.UseFirst).Task;
//asyncLoadHandle = Addressables.LoadResourceLocationsAsync(addressableLabels, Addressables.MergeMode.Intersection, typeof(GameObject));
//asyncLoadHandle.Task.Wait(100);
}
...
await LoadAddresses();
var go = possibeAddressableAssets[0];
Addressables.InstantiateAsync(go, position, Quaternion.identity, this.transform).Completed += InstantiateTile_Completed;