#SerializableDictionary but with tuple
1 messages Β· Page 1 of 1 (latest)
not that big. okay, will try to be faster!! https://pastie.io/iqwrgp.cs
FileDataHandler:Load(String, Boolean) (at Assets/Scripts/DataPersistence/FileDataHandler.cs:54)
Not in here?
Can you show that load code?
So the error is in the JsonUtility
That changes things.
Nevermind, you feed the JsonUtility OnAfterDeserialize()
Why do you do this? @idle mason
it was in the guide I was following, by the way, in the original code there is no such error on load
so it still must be something magical with my tuple dictionary
And still, this.Clear(); doesn't make much sense.
I have no idea what it is clearing at the moment, it might as well be the first list.
Seems you clear the whole dictionary to be honest π€
Can you debug.log
// deserialize the data from Json back into the C# object
loadedData = JsonUtility.FromJson<GameData>(dataToLoad);
the dataToLoad
My data to load is: {
"lastUpdated": -8585395643272775952,
"deathCount": 0,
"playerPosition": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"stepsCount": 0,
"coinsCollected": {
"keys": [],
"values": []
},
"objectsActivated": {
"keys": [
"f62f2e92-5307-48e3-886a-d9d96f2d1106"
]
},
"playerAttributesData": {
"vitality": 1,
"strength": 1,
"intellect": 1,
"endurance": 1
}
}
Debug.log what you actually save below there.
you mean gamedata data?
DataToStore
And my dataToStore is: {
"lastUpdated": -8585395627012210439,
"deathCount": 0,
"playerPosition": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"stepsCount": 0,
"coinsCollected": {
"keys": [],
"values": []
},
"objectsActivated": {
"keys": [
"f62f2e92-5307-48e3-886a-d9d96f2d1106"
]
},
"playerAttributesData": {
"vitality": 1,
"strength": 1,
"intellect": 1,
"endurance": 1
}
}
So that's also missing the values of "objectsActivated"
Figure out why that is and your problem is solved π
that's the thing, I have no idea why π¦ Do you have any more time?
No, I'm gone at least for a couple of hours. Going from work, shop, cooking, eating, gym, then maybe if I have more energy I open discord.
Okie!! Will wait for you here and if I find a solution I will tell, okay?
But I think if you put this question in #archived-code-general with this information why the values don't save you might get some help there
Yeah, ill see tomorrow for sure, maybe later tonight too, will see.
π
goodbye!
The problem was that json does not like(ignores actually) tuples π So I needed to make a struct. Which fixed the problem with saving the object's state heheh
your point was totally correct!
Awesome, happy you were able to fix it π
yess, thank you a lot!