Events Pro, this is fast and flexible event system, builded on C# delegates. With built-in editor extension. Visual part will help you to see structure of your running game in real time, and will help with profiling, bug fixing and optimizing.
Avaliable on Asset Store
Full Documentation
Event System main features:
- addEventListener
- removeEventListener
- dispatch / dispatchEvent
- stopPropagation / stopImmediatePropagation
- Events can be dispatched by string or int Ids
- Two types of listener functions avaliavle
Full Event System Documentation with use examples
Event Graph features:
- Searching
- Positions remembering
- dispatch / dispatchEvent
- 3 Collapsing modes
- Branches
- Overloaded listener detection
- Forgotten listener detection
- Listeners leaking detection
Now I whant to tell more about main idea of visual event grpah and how can it help you to make your code better. The only thing you do - is building your game as you want using this events system, and as bonus you get visualization of how your game works. And also it can work like debugging tool, with should show you where you have overloaded or forgotten listeners, or memory leaking. Here is how event graph looks for a simple example scene.
Main Features
Events Dispatch detecting.
This is the main feature of graph. When event is dispatched the conection between dispatcher class and listner becomes green for few seconds. And of course count of dispatched and resived events is chnging. So you can see in runtime how mutch events was dispathed by specific class, and how muth of them was resived by specific listner.
Searching.
There is search field in the top left corner of Graph window. So that how our graph will look if we will search “Controller”
Direct Picture URL
Positioning:
During graph construction, the elements are placed to avoid overlapping. Sometimes this is not the way you want to see your grap. That’s why it support position recording, if you move element via mouse, it position will be remembered. and in the next time it will be placed where you want it to be.
Collapsin:
If you have a lot of small listeners or dispatchers in you event graph, collapsin can make it more readable. Collapsin has three modes:
- Nothing - collapsing not working.
- Listeners - equal(same class, same listen functions) listeners will collapse in one.
- All Matches - equal listeners and dispatchers will be collapse in one.
Here is how our example graph will look like, if we will choose All Matches collapse mode.
Branches:
In the example scene you can see three separate event branches. But in real project usually much more event brunches. That’s why you can view them separately from each other.
Use Branch list to switch view to any branch or switch back to view all of them. Or you can just use “Next Brunch” button.
Element Context menu:
Right click on graph element to open context menu
Profiling and bug fixing
This extension was designed not only for visualizing your game events, but to help you profile your events.
You can find few examples of how to use it below.
Overloaded listener.
In result of some game action’s we have the same listener added twice. That’s very easy to find this kind of issue with Events Pro. If Event listened more that one time for the same listener function of the same class. Event link will become red.
Besides you can compare count of event being dispatched, and listener got called. See the picture below.
Forgotten Listener.
The gameobject with listener class was deleted, but listener, wasn’t. In that case you will get very dangerous situation, because listener class that was attached to gameobject still alive and can get events.
Picture below will illustrate grap reaction, if this kind of situation happens.
There is limit of image attached, so here is Direct Picture URL
Memory Leaking.
This two easy ways how you detect memory leaking.
- If after you finish “Playing” your game, you still see some active elements in the graph. This mean that probably your forgot to remove listener on game object destroy.
- If while your game running you can see that number of listeners is increasing or simply if there is more listeners than should be, you can be sure that you have a listener’s leak. Usually listeners leaking happens on scene changing.
Unnecessary listener.
For example you have monsters who listening mouse events. But you do need them to do this when you in pause mode. In Event Graph you see every single event that is dispatches, so you can analyze your game by looking on event graph. As result you will cut some listeners according to game current game state, etc, and save some performance!
If you whant to lear more here is Full Documentation
Inside the package you will find use exmples, and scene where you can profile and emulate errors to understand how it works.
Thanks for you time. Any suggestions or features request you can post here or send me on lacost.st@gmail.com