i feel like there is something i am doing wrong but i dont know what it is. this is the second time i am having trouble making a request for data that it fails either on the first try or the second try. i am currently trying to retrieve user data and it works the first time but when i change the data and save it i cannot retrieve the new data. i get the old data like it is being stored somewhere even though i can see it has been updated in playfab. i am trying to get key/value data. i understand this is probably going to take so time to fully explain but any help would be appreciated. here is my code:
i initially get the data here:
public static void UpdateInventoryInfo() {
for (int i = 0; i < InventoryContents.Count; i++) {
if (i < AccountInfo.Instance.Info.UserInventory.Count) {
if (AccountInfo.Instance.Info.UserInventory[i].ItemClass == GameConstants.ITEM_CARDS) {
InventoryContents[i].GetComponent<ItemSlot>().Card = AccountInfo.Cards[i];
InventoryContents[i].SetActive(true);
InventoryContents[i].transform.GetChild(0).GetComponent<Image>().sprite = AccountInfo.Cards[i].Icon;
InventoryContents[i].transform.GetChild(2).GetComponent<Text>().text = AccountInfo.Cards[i].Name;
InventoryContents[i].transform.GetChild(1).GetComponent<Text>().text = string.Format("Cost: {0}", AccountInfo.Cards[i].Cost); }
else { InventoryContents[i].SetActive(false); } }
else { InventoryContents[i].SetActive(false); } } }
this gives me an inventory that i can drag and drop from to create a hand.
public void OnDrop(PointerEventData eventData) {
if(full == 8) { return; }
ItemSlot d = eventData.pointerDrag.GetComponent<ItemSlot>();
if (d != null) {
d.parentToReturnTo = this.transform; }
if(full <= 7) {
AccountInfo.Deck.Add(card); GameObject droppedObject = eventData.pointerDrag;
AccountInfo.Deck[full] = droppedObject.GetComponent<ItemSlot>().Card;
droppedObject.tag = "Deck1";
MainSceneController.LastHand = false;
MainSceneController.CurrentCost += AccountInfo.Deck[full].Cost;
full++; } }
i save the info and it writes to the key/value, Deck/String
public static void AddToDeck() {
string deckContents = "";
foreach (CardStats item in Deck) {
deckContents += item.Name + ","; }
Dictionary<string, string> data = new Dictionary<string, string> { {
GameConstants.DATA_DECK, deckContents } };
UpdateUserDataRequest request = new UpdateUserDataRequest() {
Data = data };
PlayFabClientAPI.UpdateUserData(request, GotData, GameFunctions.PlayFabAPIFailure); }
private static void GotData(UpdateUserDataResult result) {
Debug.Log("Account Info Got Data Updated Data"); }
this works and i get the debug statement in the console everytime i save. i try to retreive the data like this:
public static void UpdateTheDeck() {
UserDataRecord temp;
if(Instance.Info.UserData.TryGetValue(GameConstants.DATA_DECK, out temp)) {
Instance.deckInfo = temp.Value.Split(',');
for (int k = 0; k < Instance.deckInfo.Length - 1; k++) {
for (int j = 0; j < Instance.Info.UserInventory.Count; j++) {
if (Instance.deckInfo[k] == Instance.Info.UserInventory[j].ItemId) {
Deck.Add(Database.GetCardInfo(Instance.Info.UserInventory[j], j));
break; } } } }
MainSceneController.UpdateDeckInfo(); }
it works the first time but if i change the data and resave it, then try to retreive it i get the old data and not the new data like it is somehow being stored somewhere even though i can see in playfab that the key/value has been updated each time i save. also as a note if i quit the app and restart i get the new data like it has been there all along. i will be glad to provide any code that i have left out and again i think there is something that i dont understand when retreiving key/data. any help will be appreciated. thanks.