Hello, I wanted to know how I could display the player's Playfab inventory ingame. Like you press a button and it brings up a menu showing all your Playfab items.
Hello, I wanted to know how I could display the player's Playfab inventory ingame. Like you press a button and it brings up a menu showing all your Playfab items.
If you want to get the inventory of a player, the proper API is GetUserInventory, and as you can see, GetUserInventoryResult contains 3 properties, where inventory is stored as a list of
ItemInstance. ItemInstance is a property created by PlayFab and it has been predefined and contained in Unity SDK. You can find the documentation on https://docs.microsoft.com/en-us/rest/api/playfab/client/player-item-management/getuserinventory?view=playfab-rest#iteminstance.
Please understand that in the PlayFab community forum, we are glad to help with PlayFab related questions like API usage, property type, etc. In terms of UI design on Unity Engine, we cannot provided very detailed and professional support since we are not expert on it. There are Unity samples on PlayFab official repository, however, we will still suggest finding more help on Unity developer community if you need dedicated support.
Thank you I really don't need help like attaching an inventory to the UI or anything my main question was how to return all items in the players inventory on Playfab without using static classes.
May I ask what do you mean by static classes? Do you mean the pre-defined types that defined in PlayFab SDK? Can you provide an example?
PlayFab Unity SDK also includes PlayFabSimpleJson methods, you can stringify any returned objects in the callback result.
Like in this example:
I already have something that can display VC without static classes but im not sure how I can change it to return inventory items:
Please always refer to the API document: GetUserInventory.
The successful callback GetUserInventoryResult contains 3 properties, which are Inventory, VirtualCurrency and VirtualCurrencyRechargeTimes, where Inventory is a list of ItemInstance and VirtualCurrency is an Object.
Hence, to retrieve the inventory:
var itemList = GetResult.Inventory;
In terms of ItemInstance[], it is pre-defined in the SDK :
public List<ItemInstance> Inventory;
and ItemInstance is pre-fined in PlayFabClientModels.cs
public class ItemInstance : PlayFabBaseModel { public string Annotation; public List<string> BundleContents; public string BundleParent; public string CatalogVersion; public Dictionary<string,string> CustomData; public string DisplayName; public DateTime? Expiration; public string ItemClass; public string ItemId; public string ItemInstanceId; public DateTime? PurchaseDate; public int? RemainingUses; public string UnitCurrency; public uint UnitPrice; public int? UsesIncrementedBy; }
Basically you may retrieve anything you want.
Hmm it doesn't seem to return the items to List. Do I need a Dictionary like I had at the top of my GetVC function?
I think it is necessary.
GetResult.VirtualCurrency is a normal Dictionary<string, int> type. However, you may also use Implicitly type via "var".
Meanwhile, List<ItemInstance> is defined by PlayFab SDK. If you need to use externally, it will be better to declare definition in the begining.
Hmm I don't know how to make a definition for "ItemInstance".
2 People are following this question.
Converting PlayFab Info to Player Object
Sometime purchases are not being granted, with no trace in event history?
Change recharge maximum per player
Can't figure out how to get the consume count of all items in player inventory
Is there an overview of which API calls can and cannot be ran synchronously?