How to store data?
Hi. I need store data that will the code memory. For example: You are playing game and you need to save your position, but you can't obviously store that in code. Where should I store data?
9 Replies
I thought JSON can help me, but it's too hard.
A JSON file should be perfectly fine
Make a class to represent your saved data
Then
File.ReadAllText()
to read the file, JsonSerializer.Deserialize<TheClass>()
to turn it into an instance of the class
JsonSerializer.Serialize()
and File.WriteAllText()
to save the changed settings
EzOkay, do you have some good tutorial? I just need to get number of level and then re-write to new
And I can't find some good tutorial for just this
Quite literally just what I wrote could serve for a tutorial
'Ere
Ok, thanks
Yeah, JSON is the easiest way to go. But if you have a lot of data and need to be compact and performant, then you can try using some binary serializer
GitHub
GitHub - Cysharp/MemoryPack: Zero encoding extreme performance bina...
Zero encoding extreme performance binary serializer for C# and Unity. - GitHub - Cysharp/MemoryPack: Zero encoding extreme performance binary serializer for C# and Unity.
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
MessagePack is still better if you need to interop with other languages