- Home /
[OnSerialize] and other events doesn't work
I am currently working with the DataContractSerializer (under the 'System.Runtime.Serialization' namespace), but i cannot get the [OnSerialize], [OnDeserialize], [OnSerialized] events to work. is this a known unity problem? it seems that other people, using DataContractSerializer without unity, have no problem with this... i tried using Debug.Log in the methods, and i tried changing values in my object (if it was a problem with the Debug.Log), but to no effect.
Do anyone know of any known problems with this? i found another, unanswered, question where the person had more or less the same problem, but again - it was unanswered and very old, so not much help there..
The serializing is not the problem - it works fine but this following method does nothing, even though the classes are infact serialized:
[OnSerializing()]
void OnDeserialized(StreamingContext c) {
SetInnerVector(new Vector2(1, 2));
}
after playing around with Visual Studio, i quickly figured out that is is infact a unity-problem - i have no problem with doing this in a normal Console Application..
I can confirm that behaviour. I can't get the OnDeserialized callback working. Has anyone a solution ?