When [Serializable] class that implements ISerializationCallbackReceiver is deserialized with JSONUtility, it triggers both its required methods
- before serialization it triggers OnBeforeSerialize
- after deserialization it triggers OnAfterDeserialize
Im now using Protobuf-net for deserialization.
I can’t get OnAfterDeserialize trigger after deserialization. Is there an easy way to make protobuf-net trigger that?
Simple, actually. Protobuf-net already has support through Attributes.
Example of how this is handled with protobuf-net:
-
You don’t need to use ISerializationCallbackReceiver interface for your class.
-
You decorate your functions to be called after/before serialization and after/before deserialization with these Attributes:
[ProtoAfterDeserialization]
[ProtoAfterSerialization]
[ProtoBeforeDeserialization]
[ProtoBeforeSerialization]