Events System Documentation

Evebts Pro this is fast and flexible event system for Unity, builded on C# delegates. It’s similar to well known AS3 event system. Just read the method description and you will understand how it work and how it can help you with your game.

Event system documentation

There Is two main classes (EventDispatcher  and EventDispatcherBase) with allow you to implement eventing tou your game.  They do the same, but EventDispatcher is inherited from MonoBehaviour and EventDispatcherBase is just a System.Object.

if you want your script to be able to dispatch events you should inherit it from EventDispatcher or EventDispatcherBase.


Methods description

Here is methods description of EventDispatcher and EventDispatcherBase classes.

// Adds events listener do the dispatcher. You may use two types of functions (with or without additional data) and two types of event identification (string of int)
public  void  addEventListener(string eventName, EventHandlerFunction handler)
public  void  addEventListener(int eventID, EventHandlerFunctio handler)
public  void  addEventListener(string eventName, DataEventHandlerFunction handler) 
public  void  addEventListener(int eventID, DataEventHandlerFunction  handler) 

// Removes events listener from the dispatcher.
public  void  removeEventListener(string eventName, EventHandlerFunction handler)
public  void  removeEventListener(int eventID, EventHandlerFunction handler)
public  void  removeEventListener(string eventName, DataEventHandlerFunction handler) 
public  void  removeEventListener(int eventID, DataEventHandlerFunction handler) 
// Dispatches the event
public  void  dispatchEvent(string eventName)
public  void  dispatchEvent(string eventName, object data)
public  void  dispatchEvent(int eventID)
public  void  dispatchEvent(int eventID, object data)

public  void  removeEventListener(string eventName)
public  void  dispatch(string eventName, object data)
public  void  dispatch(int eventID)
public  void  dispatch(int eventID, object data)

// Remove all listners from the dispatcher
public  void clearEvents()

If you need to send some data via your events. You should use dispatcher function with contains data filed. In order to receive this data, your data function should have CEvent as parameter.

Note: If you dispatch event with additional data, and you have some listeners that do not have CEvent as parameter thay will be called any way.

Note: Because the EventDispatcher is inherited from MonoBehaviour it can detect what gamobject is destroyed, and clean up all listeners on destroy. This feature can save you from dangerous situations when you forgot to remove listener. But I do not recommend to rely on this feature, it only designed for hedging. Besides EventDispatcherBase not able to do that.


Here is  properties and methods description of CEvent class.

// Event id, if you are using int event identification. And if you use string event identification it will contain HashCode of string identificator.
public int id {get;}

// Name of the event if you use string event identification. Contains string.Empty if you are using int event identification
public string name {get;}

// Event data, that you have sended via dispatcher function. Null if you use dispatcher function without data parametr.
public object data {get;}

// Event target. Contains link to the dispatcher class of this event
public IDispatcher target {get;}
public IDispatcher dispatcher {get;}

// Contains current event target
public object curentTarget  {get;}


Note: curentTarget contains link to the class with currently receive the event. target contains like to the class who has dispatched the event.

You can read more this post to understand difference between them.

// Will stop event propagation, but listener functions of class with has received last event still be able to get event.
public void stopPropagation()

// Stop Event propagation immediately
public void stopImmediatePropagation()


Note: You can also read this and this post, to better understand difference between stopPropagation and stopImmediatePropagation.