Hi everyone,
I’ve been a fan of using delegates and events for communicating different parts of the project without the need for parts to know about each other. This is pretty good for decoupling code and to have much more modularity. For a long time, I thought there was no downside to it.
The way I’ve been doing it so far for the most part is by having a scriptable object acting as a middle-man between 2 or more parts that have to communicate. This scriptable object acts as an “event handler” that gets called/triggered by the part that wants to transmit data and sends an event that other parts can listen to. This is good for an infinite amount of things, such as updating scores, UI, animations, and so on.
However, I’ve noticed that sometimes it doesn’t come in handy. For instance, if the part that triggers the event wants to perform a series of actions in sequence/order, then delegates or events (at least in the way I used them) don’t seem to be adequate. For example, imagine I want to do the following in order within a method: (1) perform action 1 > (2) perform action 2 > (3) trigger a specific event (that another part is subscribed and performs action 3) > (4) action 4. In this case, action 4 would be performed before action 3 no matter what, since the sequential order within the method has priority over the event that is been listened to in, most likely, another script. In fact, I’m not sure in which exact moment the action 3 will happen within the frame logic, which, in certain cases, could screw things up when order is crucial.
I just wanted to know whether you have faced these kinds of scenarios, what your stance is on this, and what practices you guys normally do for these cases.
Have a great day and thanks for reading!

