The new Messaging System is weird

Today I suddenly see the class ExecuteEvents ,and it’s function:
ExecuteEvents.Execute(GameObject target, BaseEventData eventData, EventFunction functor);

I have to say I am confused , why I need to know the target. I mean the publisher do not need to know the subscriber for OOP reason. if I have definitely known the target ,why I don’t just call it’s function directly (for a better performance).

The manual say “The messaging system is generic and designed for use not just by the UI system but also by general game code” . If this is really for generic usage.I think they should consider how to make it more loose coupling.

1 Like

This is for loose coupling. The target is a GameObject, not a specific MonoBehaviour. It will find any scripts on the target GameObject that implement the interface.

This function is meant to be a replacement for SendMessage.