Edit: Looking through the API, I think I can do what I need by using the tag form of reading/writing. That it's not sequential and I can make use of TagExists.
Edit2: I've given it a try but I must be doing something wrong. This code: https://pste.me/#/2o0fi/5fxXMoy01TtwmR8 ... kFg7uMFNYE writes just fine, the files are written, they seem to be about 600k depending on the data but when I try to read from them, I get the error:
Code: Select all
ES2InvalidDataException: Easy Save 2 Error: The file provided does not contain data that is readable by Easy Save. Please make sure that file was created by Easy Save.
ES2Reader.Next ()
ES2Reader.ScanToTag (System.String tag)
ES2Reader.ProcessHeader (Key expectedCollectionType, .ES2Type expectedValue, .ES2Type expectedKey, System.String tag)
ES2Reader.Read[Chunk] (System.String tag)
ES2.Load[Chunk] (System.String identifier)
SaveManager.LoadChunk (Vector2 chunkVec) (at Assets/Scripts/Saves/SaveManager.cs:68)
World.loadChunk (Vector2 chunkVec) (at Assets/Scripts/World/World.cs:154)
World.loadChunksAround (Vector2 origin, Int32 radiusX, Int32 radiusY) (at Assets/Scripts/World/World.cs:198)
TilingEngine.Update () (at Assets/Scripts/Rendering/TilingEngine.cs:41)
Unless there's something better that I'm missing, I've solved this for now by using a boolean which is always written to the file, and tells me whether the next piece of optional data exists.
Code: Select all
var hasEntity = reader.Read<bool>();
if (hasEntity) {
// read it here
}