I’m trying to Serialize and Deserialize a world to make a save/load system but I’m getting an error message when running DeserializeWorld and I have no idea how to fix it.
Here’s the error:
We are reading a UnityEngine.Object however no ObjectTable was provided to the PropertiesBinaryReader.
Here’s my code:
// Serialization
var file = Application.persistentDataPath + "/test-save.dat";
BinaryWriter writer = new StreamBinaryWriter(file);
SerializeUtility.SerializeWorld(EntityManager, writer);
writer.Dispose();
// Deserialization
var file = Application.persistentDataPath + "/test-save.dat";
var world = new World("Deserialization World");
var entityManager = world.EntityManager;
BinaryReader reader = new StreamBinaryReader(file);
SerializeUtility.DeserializeWorld(entityManager.BeginExclusiveEntityTransaction(), reader);
entityManager.EndExclusiveEntityTransaction();