I need to update the Database on Parse.com when a user quits the game. I have the inventory class check OnApplicationQuit() and when it does, it calls a SaveInventory function which saves to the Parse.com Database.
I know that the SaveInventory function works, if I call that at any point during the normal game, it saves as it should. When OnApplication is Called, Every Debug.Log in SaveInventory is called as it should be. Does anyone know how I can update the database when a user quits.
Here is my SaveInventory function:
public void SaveInventory(DictionaryOfStringAndInt inventory) {
Debug.Log("Save Starting");
myInventory = inventory;
inventoryData.SaveAsync().ContinueWith(t => {
List<string> slots = new List<string>() {
"slot01", "slot02", "slot03", "slot04", "slot05", "slot06",
"slot07", "slot08", "slot09", "slot10", "slot11", "slot12",
"slot13", "slot14", "slot15", "slot16", "slot17", "slot18",
"slot19", "slot20"
};
int slotsIndex = 0;
inventoryData["coins"] = myInventory["coins"];
foreach (KeyValuePair<string, int> item in myInventory) {
if (item.Key == "coins") continue;
inventoryData[slots[slotsIndex] + "Name"] = item.Key;
inventoryData[slots[slotsIndex] + "Amount"] = item.Value;
Debug.Log(slots[slotsIndex] + "Name" +": " + item.Key + " - " + slots[slotsIndex] + "Amount" + ": " + item.Value);
slotsIndex++;
}
inventoryData.SaveAsync().ContinueWith(tt => {
Debug.Log("WHAT");
});
Debug.Log("Save Completed");
});
}