Hello, how do I call on the variable of a Currency or a Catalog Item into Unity as a SetText to display the number of "X Currency" and the number "Y Catalog Items" into a Text object?
Hello, how do I call on the variable of a Currency or a Catalog Item into Unity as a SetText to display the number of "X Currency" and the number "Y Catalog Items" into a Text object?
For “the variable of a Currency”, API GetUserInventory can return you a list of users’ virtual currency balances in call back result.
For “ Catalog Item”, API GetCatalogItems can return you information of items in your specific catalog in call back result too.
Please refer https://api.playfab.com/docs/getting-started/unity-getting-started to learn how to make use of these API in Unity.
Unity http request code shown as below.
PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest { }, (result) => { int CurrenyBalance = result.VirtualCurrency["YourCurrencyName"]; }, OnGetError); PlayFabClientAPI.GetCatalogItems(new GetCatalogItemsRequest { }, (result) => { foreach (var item in result.Catalog) { print(item.DisplayName + item.VirtualCurrencyPrices["YourCurrencyName"]); } }, OnGetError);
Once the data comes back, combine them into a string and set your Text component’ text as your combined string. Code looks like below:
public GameObject yourTextGameObject; yourTextGameObject.GetComponent<Text>().text= yourCombinedString;
If you have any other question or I misunderstood your question, please let us know.
1 Person is following this question.