I've tried a basic implementation of 'ISerializable', but it doesn't seem to work when ES3 is saving my class.
And I found no references to 'ISerializable' in ES3 code.
Have I missed something?
If I haven't and ES3 do not call 'GetObjectData()', is there a way to call a given method when ES3 is serializing a standard class (not a custom ES3 type)?
Does 'ISerializable' work with ES3?
Re: Does 'ISerializable' work with ES3?
Hi there,
Easy Save does not use the ISerializable interface because the majority of Unity's API does not use it at runtime.
Also Easy Save does not have anything similar to GetObjectData() as it writes data directly to the stream, which significantly reduces memory usage and improves performance.
If you need to control what is serialised, you will need to use the Window > Easy Save 3 > Types panel, or create an ES3Type.
All the best,
Joel
Easy Save does not use the ISerializable interface because the majority of Unity's API does not use it at runtime.
Also Easy Save does not have anything similar to GetObjectData() as it writes data directly to the stream, which significantly reduces memory usage and improves performance.
If you need to control what is serialised, you will need to use the Window > Easy Save 3 > Types panel, or create an ES3Type.
All the best,
Joel
Re: Does 'ISerializable' work with ES3?
Unfortunately I cannot use an ES3Type, as modders must be able to export/import their own custom data.Joel wrote:Hi there,
Easy Save does not use the ISerializable interface because the majority of Unity's API does not use it at runtime.
Also Easy Save does not have anything similar to GetObjectData() as it writes data directly to the stream, which significantly reduces memory usage and improves performance.
If you need to control what is serialised, you will need to use the Window > Easy Save 3 > Types panel, or create an ES3Type.
All the best,
Joel
All I need is a custom method being called just prior to serialize the data, so I can prepare the data for ES3 to serialize them properly.
I'll take a look into the code to find out where serialization for classes is done in ES3 and add a call to a custom function if an 'IES3Serialize' interface is implemented.
If you can provide any indication about where I should look in the code in order to find where to call such a method, it will help a lot.
Re: Does 'ISerializable' work with ES3?
Hi there,
Automatic serialisation (i.e. when no pre-existing ES3Type exists) happens in the Write and Read methods of ES3ReflectedType.
All the best,
Joel
Automatic serialisation (i.e. when no pre-existing ES3Type exists) happens in the Write and Read methods of ES3ReflectedType.
All the best,
Joel
Re: Does 'ISerializable' work with ES3?
Thanks for the tip.Joel wrote:Hi there,
Automatic serialisation (i.e. when no pre-existing ES3Type exists) happens in the Write and Read methods of ES3ReflectedType.
All the best,
Joel
I'm not sure why, but I had to put the call in the 'Write()' method of the 'ES3ObjectType' type, but it was close enough.
Anyway now it works fine for my needs, thanks again!
It's very handy to be able to execute some code just before Serialization begins.
It may also be interesting to be called when serialization ends.
Maybe it could a be future feature in ES3, offering the possibility to associate callbacks to some types with a syntax like 'SetOnPriorSerializationCallback(Type, Action)' and 'SetOnPostSerializationCallback(Type, Action)'.