So I have been trying to get serialization and deserialization to work forever now but I could figure it out. it “works” but it take a few minute to save and load even a single chunks any clue what I could do? https://github.com/ballfu/hahaChunkSavingGoesBrrrrrrr
basically I’m trying to load and save chunks (kinda like how minecraft handle save data)
here’s what each script does
envSave.cs Main script I’m using to handle saving and loading
Chunkgus.cs the class I’m trying to serialize basically a collection of chunk class
Chunk.cs store a 3d array of blockdata (1612816 in size)
BlockData.cs store the actual data of a block
TerrainBlockData.cs a sub set of blockdata (planing to get rid of it haven’t doe it yet)
tldr: serialization too long both ways and either I’m doing something very wrong or I need something that’s alot faster than BinaryFormatter
Your array is ~30,000 elements. That’s a lot, but definitely not “takes minutes to process” a lot. But it also depends on how many of them you have. One thing you can do is use Unity’s Profiler to figure out what’s taking so long.
I have tried to profile it and it just formatter.Serialize and formatter.Deserialize that’s take up most of the time and also all the code I’m using to load and save should be in the github linked (if I din’t missed anything)
Since you are returning the original array from this property getter, it’s possible for the array to be modified without setting chunkWasEdited = true like what happens in the setter.
It been a while since I profile it and the call amount vary each run but I think serialize think like 0.5 second per call and a few second per deserialize if I remember correctly. but a recent run of the code with all the rendering takes around 50 seconds (it loads around 4 file without loading it’s only take a few seconds to generate the chunk plus rendering)
the rendering is not the problem (i havent yet reprofile saving it and the number are off my memory and loading stll take a few second anyways which is still too long)