Posted June 20, 2023 by Brad Dallimer
I tried a new approach to pass references of events and variables between many scripts to achieve as much cross-compatibility and decoupling as possible. I achieved this using an interface, generics, and the Observer Pattern.
A parent script will implement the IEventAndDataHandler interface to allow other scripts to interact with it. This parent script acts as the subject and all the scripts that reference the interface are the observers.
I designed this interface to be useful in many different use cases and perhaps I will use this in future projects to limit coupling and encourage scalability.