I have a set of prefabs with a component storing two values for filter (an int and a byte). I’m looking for a way to filter them at runtime before intantiation, something like a label mask but :
I can’t find labels from IResourceLocation
Create a data table to store these values along with the relative prefab key seems pretty redundant with the addressable system
Parsing key strings to find an int and a byte looks weird…
I feel like I’m missing something. How would you achieve this ?
If you know asset key and label than you can iterate through AllResourceLocators and their keys and locate only keys that matches the label. Each label based key will contain set of resource locations of assets that have that label. You can check if there is a location with matched primary key ( name based key).
So I should Locate twice (once for each label) and extract the locations only if they are in both ? There is no way to attach data to the addressable entry and get them along with the IResourceLocation ?
Problem is it looks like a better way to handle a custom lookup table here, and I’m not sure why or how I should use Addressables in such a case.
Obviously you can not filter entries data without loading them first. Unless you can attach extra data into the system, which is not currently available. I wonder whether unity dev would like to add this feature. If you see how it implements, the system flatten all keys (address or label) into catalog, and treat them with no difference. That’s why you can not easily get label for an address in runtime. So even label are not treated as an additional data for an address…
However since you mentioned label mask, you can checkout the merge option below, and use it to get an intersection of [prefab_label, filter_label].