In an ItemInstance, where can I find the tag(s) in C# with Unity?
(Sorry about so many posts recently haha I've been on a PF rampage!)
EDIT: Forgot img
In an ItemInstance, where can I find the tag(s) in C# with Unity?
(Sorry about so many posts recently haha I've been on a PF rampage!)
EDIT: Forgot img
The problem your having is that you are trying to access a CatalogItem property with a ItemInstance object.
So long story short to get the tags for a ItemInstance you must search through your catalog of items for the matching item. ItemInstance.ItemId == CatalogItem.ItemId. From there you can use CatalogItem object and get the tags by doing CatalogItem.Tags.
Please see this post for more info on the topic of mapping ItemInstance objects to CatalogItem objects.
This is the answer - cheers! ..But it (the API/SDK) is definitely not intuitive if this is still the main way to do it. To save time, a lazy workaround would be to store tags in annotation and just split() with commas. Would also save processing if you don't have to iterate.
This really needs to be changed or everyone will have different ways of doing the core functions instead of having a standard like most other calls
EDIT: Added feat req https://community.playfab.com/idea/5738/make-items-more-intuitive-in-terms-of-accessing-ce.html
EDIT 2: @Joshua Strunk I just saw your comment - I think I see what you're saying - I'll try it out.
In this situation I always recommend when you pull a catalog from PlayFab just instantly build a dictionary. Dictionary<string, CatalogItem> catalog. This is instead of storing it as returned by the API as a List<CatalogItem>. You can still iterate through all the items in dictionary if needed and this allows you to quickly map ItemInstances to CatalogItems by doing catalog[itemInstance.ItemId].
2 People are following this question.