I have more than 1 catalog in the playfab inventory. each catalog has its items. i want to get user inventory specifically to a catalog. I want to know is this possible? if possible then how to do it and if not any wayaround to solve it.
I have more than 1 catalog in the playfab inventory. each catalog has its items. i want to get user inventory specifically to a catalog. I want to know is this possible? if possible then how to do it and if not any wayaround to solve it.
public void GetUserInventory() { var request = new GetUserInventoryRequest(); PlayFabClientAPI.GetUserInventory(request, result => { Debug.Log("UserInventory"); foreach (var item in result.Inventory) { } DataManager.Instance.itemList = DataManager.Instance.MapInventory(result.Inventory); DataManager.Instance.MapInventoryCards(); }, error => { }); }
You can use GetUserInventory to get the current user's inventory, traverse the items in the inventory in the callback, and determine whether the CatalogVersion of each item is the same as the catalog you want.
If your platform is Unity, you can refer to the code below.
public void GetUserInventory() { List<ItemInstance> itemList = new List<ItemInstance>(); PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest(), (result) => { foreach (var item in result.Inventory) { //Debug.Log(item.DisplayName + ":" + item.CatalogVersion); if (item.CatalogVersion == "Your CatalogVersion/CatalogName") { itemList.Add(item); } } DataManager.Instance.itemList = DataManager.Instance.MapInventory(itemList); DataManager.Instance.MapInventoryCards(); }, (error) => { Debug.LogError(error.GenerateErrorReport()); }); }
8 People are following this question.