Created
November 18, 2019 21:13
-
-
Save Badgerdox/7ed8807769ac69e334dba0beb8f6365b to your computer and use it in GitHub Desktop.
Search through multiple labels and Instantiate for a single label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create All Addressable Assets from Multiple Labels