So i am new to playfab and i want to make a store in my unity game where you can see the name of the item and the cost of the item like a list scroll view . But i don't know how to get the display name and the price from the playfab store and i also want to list the item. I tried searching for tutorial but no luck ): please tell me the code used to do this.
Answer by Gosen Gao · Jun 06 at 08:09 AM
You can use API GetStoreItems to get the item’s info for a specific store. But it is not include the DisplayName, you may need to call API GetCatalogItems to get the DisplayName. Or you can add the DiaplayerName to the store item’s CustomData. Usually, it is recommended to locally cache catalog items for future reference. With code below you can get item’s ItemId, DiaplayName and prices, then you can use it to implement UI in the game.
public Dictionary<string, CatalogItem> Map = new Dictionary<string, CatalogItem>(); void Start() { PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest { CustomId = "Gosen" }, result => { GetCatalogItems(); }, error => { Debug.Log(error.GenerateErrorReport()); }); } public void GetCatalogItems() { PlayFabClientAPI.GetCatalogItems(new GetCatalogItemsRequest { CatalogVersion = "Main" }, result => { foreach (CatalogItem item in result.Catalog) { Map.Add(item.ItemId, item); } GetStoreItems(); }, error => { Debug.Log(error.GenerateErrorReport()); }); } public void GetStoreItems() { PlayFabClientAPI.GetStoreItems(new GetStoreItemsRequest { StoreId = "TestStore", }, result => { foreach (var item in result.Store) { Debug.Log("ItemId:" + item.ItemId); Debug.Log("VirtualCurrencyPrices:" + item.VirtualCurrencyPrices["GC"]); Debug.Log("DisplayName:" + Map[item.ItemId].DisplayName); } }, error => { Debug.Log(error.GenerateErrorReport()); }); }
IAP Guide Parity 1 Answer
Start multiplayer server from cloud script 3 Answers