Please split ISerializationCallbackReceiver into two separate interfaces

Please split the interface ISerializationCallbackReceiver into two separate interfaces ISerializationOnBeforeReceiver and ISerializationOnAfterReceiver.

The reason behind this is simple. Often, as a developer, you only need to react to one of the two callbacks in your component, but the interface forces you to implement both, leaving one method completely empty.

One example is the transformation of serializable objects into objects that are not supported by the serialization system of Unity. One might want to transform these objects with no intention of changes being propagated back, which is especially true for runtime, aiming to change the representation of an object into a more fitting object to optimize certain scenarios.

Splitting the interface into two ones could provide a performance boost after optimization, similar to how Unity encourages that empty Update() and Start() should be removed because they drain performance even if they do nothing.

You would probably end up with something like, allowing the change to be backwardly compatible:

public interface ISerializationCallbackReceiver : ISerializationOnBeforeReceiver, ISerializationOnAfterReceiver
1 Like

I’ve forwarded your feedback to the devs and they agreed that it makes sense. They couldn’t commit to implementing it yet but are aware of the request.

1 Like

Thank you for forwarding it, if I stumble upon community examples during my work where the current problem of being forced to implement both methods is highlighted, I make sure to post them here. I not only stumbled upon them in the past myself, I did see them in shipped code that I bought, just happen to not remember where exactly, even after small searches not finding them.