Custom Event System for Unity

Share:Tweet about this on TwitterShare on RedditPin on PinterestShare on FacebookShare on LinkedInShare on Google+

The Unity built-in event system is good for simple stuff and basic message sending. But when it comes to sending complex data or deactivate listeners it doesn’t fit well for that.

If you want a more customizable system you could use my event system:

EventNotification

I developed it (in C#) starting from the following class, than I extended it to satisfy my needs:

NotificationCenter

This event system allows you to define a specific event class (with all the benefits of encapsulated data), to add and remove listeners from a specific event and to define a callback for that event.

It’s safer than the Unity standard system, since it uses a delegate (like a function pointer) to specify callbacks, instead of strings (typo unsafe). It also uses the class name to differentiate events, and a listener has to use the type of the event to which it wants to react.

Use it freely on your projects. Happy coding!

I define myself as a creative developer.

I define myself as a creative developer.