Honestly, I like a system based around the interface (may it be explicit with an interface or just reflected from the classes interface). And my reason is less boilerplate code.
If events were used, you’d have to register for the event. This requires some boilerplate at the ‘Awake’/‘Start’ of the script.
Where as with the current reflected interface, or the more explicit interface, unity just determines if those methods exist, and wires them for you.
And for general purpose scripting by your regular designer (rather than engineer), this is easy.
It has it’s down sides… you can’t unregister an event on a whim at runtime. That’s annoying.
But in the same respect, the implementation of an events based system comes with some issues on the unity side. Currently, with the event registration known by the interface of the class (if the class has a method defined), it can preemptively categorize scripts into pools of who is and is not registered for an event. This reduces costs of calling those events… ignore all scripts that don’t have an ‘update’ function.
If it used the .net events, like:
It’s a bit more difficult to preemptively know who is registered for what events with out cycling through them. They’d have to long hand implement the events ‘add/remove’ methods, and insert/remove the classes from the event pool so that it wasn’t checking the scripts every frame. This means registering would be heavier.
Furthermore calling these events would be inverse of the event system design. An event system dispatches events from an object to the other. The event can only be called by itself. So behind the scenes, unity would have to have a caller function on each script that calls the event, so the script can receive its own event. Unnecessarily increasing the stack call length.
And a minor quibble could be the object overhead of having to create delegates for every registered method to the event.
Of course they could also use a ‘AddListener(someDelegate)’ function, but again… we have all the quibbles of the .net event system… with the exception of the increased call stack because the delegate isn’t restrained by the call direction of th event.
And of course they could also use a ‘AddListener(ICallbackReceiver)’ funciton, ala Java-like event messaging systems… but that is really the interface system you said you think unity might be implementing. Just with the added necessity of the actual boilerplate code to add/remove.
This one I could go with… get a best of two worlds.
Have it where if the interface is implemented, the script is registered for the event automatically by the unity system. But the script itself could called ‘RemoveListener’ or ‘AddListener’ at runtime to register and unregister. Removing boilerplate code, but giving the runtime swapping.