Skip to content

Instantly share code, notes, and snippets.

@Badgerdox
Created November 18, 2019 21:13
Show Gist options
  • Save Badgerdox/7ed8807769ac69e334dba0beb8f6365b to your computer and use it in GitHub Desktop.
Save Badgerdox/7ed8807769ac69e334dba0beb8f6365b to your computer and use it in GitHub Desktop.
Search through multiple labels and Instantiate for a single label
public static class CreateAddressablesLoader
{
public static async Task SearchByLabels<T>(List<string> labels, bool removeDupes, List<T> createdObjs)
where T : Object
{
IList<IResourceLocation> locations = new List<IResourceLocation>();
foreach (var label in labels)
{
foreach (var resourceLocation in await Addressables.LoadResourceLocationsAsync(label).Task)
locations.Add(resourceLocation);
}
if (removeDupes)
await FindDuplicateEntries(locations, true);
foreach (var location in locations)
{
createdObjs.Add(await Addressables.InstantiateAsync(location).Task as T);
}
}
}
@Badgerdox
Copy link
Author

Create All Addressable Assets from Multiple Labels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment