Hello I'm trying to make a script in unity that displays all the usage count of all items in the player's inventory. My code seems to only grab the last item in the players inventory and none of the others. I would like to have it grab each item and assign each of the items usage counts to a string.
Code:
using PlayFab; using PlayFab.ClientModels; using PlayFab.ProfilesModels; using PlayFab.DataModels; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class InventoryViewManager : MonoBehaviour { public GameObject uiParent; public GameObject sampleCanvas; public Text Item1Value; public Text Item2Value; public Text Item3Value; public Text Item4Value; private Vector3 RowStart = new Vector3(0, 15); private Vector3 ItemOffset = new Vector3(0, 175); void Start() { sampleCanvas.SetActive(false); } public void ViewInit() { sampleCanvas.SetActive(true); PlayFabClientAPI.GetUserInventory(new PlayFab.ClientModels.GetUserInventoryRequest(), UpdatePlayerInventory, OnError); } public void UpdatePlayerInventory(GetUserInventoryResult result) { var pos = new Vector3(RowStart.x, RowStart.y); var parentOffset = uiParent.transform.position; foreach(var item in result.Inventory) { var itemView = uiParent.transform.Find(CatalogViewItem.getIconFromItemId(item.ItemId)); Item1Value.text = item.RemainingUses.ToString(); } } private void OnError(PlayFabError error) { Debug.Log(error); //PopupError.ShowErrorMessage("PlayFab", error.GenerateErrorReport()); } }