I am trying to serialize arrays independend from their index so even when i change index of an item it loads from its ID. Tried it with
using ES2Writer and ES2Reader and it works perfect
But i tried it implementing in ES2Type and got an error
so here is how i am doing it
Code: Select all
public class ES2UserType_VehicleContainer : ES2Type
{
public override void Write(object obj, ES2Writer writer)
{
VehicleContainer data = (VehicleContainer)obj;
// Add your writer.Write calls here.
writer.Write(data.unlocked, string.Format("status{0}", data.itemID));
}
public override object Read(ES2Reader reader)
{
VehicleContainer data = new VehicleContainer();
Read(reader, data);
return data;
}
public override void Read(ES2Reader reader, object c)
{
VehicleContainer data = (VehicleContainer)c;
// Add your reader.Read calls here to read the data into the object.
data.unlocked = reader.Read<bool>(string.Format("status{0}", data.itemID));
}
/* ! Don't modify anything below this line ! */
public ES2UserType_VehicleContainer():base(typeof(VehicleContainer)){}
}
Code: Select all
Exception caught while invoking the method named SaveL from an inspector button. The exception was "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." and the stack was " at ES2Reader.Next () [0x00000] in <filename unknown>:0
at ES2Reader.DeleteTags (ICollection`1 tags, .ES2Writer writer) [0x00000] in <filename unknown>:0
at ES2Writer.Delete () [0x00000] in <filename unknown>:0
at ES2Writer.Save (Boolean checkForOverwrite) [0x00000] in <filename unknown>:0
at ES2Writer.Save () [0x00000] in <filename unknown>:0
at ES2.Save[ListItemSerializationTest] (.ListItemSerializationTest[] param, System.String identifier) [0x00000] in <filename unknown>:0
at VehicleManager.SaveL () [0x0000c] in C:\Users\med_c\Documents\gitrepos\blocky_dev_project\blockypursuit\Assets\BPFiles\Scripts\Game\VehicleManager.cs:71
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
.
.
.
.
.