The UnityEvent visualizer

About one year ago I was hired to help with a Virtual Reality project for a massive sci-fi movie. I was very excited as I love the genre and that saga in particular is great… then I saw the Unity project!
We all have been there: a project with little direction at the beginning where different agencies have taken care of animations and sounds respectively without worrying too much about how to hold everything together. Once all the mess is done then you call the programmers to work on it.

In this case the mess was caused by the incredible abuse of UnityEvents in the inspector. Event driven programming is a very powerful technique that allows a lot of flexibility, sometimes way too much flexibility. But in Unity it is particularly bad when the events are wired in the inspector instead of in code. That means that Visual Studio will be unable to follow the trail back to who-called-what and suddenly you cannot debug anything.

For that reason I created the UnityEventVisualizer. This is a node graph representing all the UnityEvents that are wired in your scene: each node represents a GameObject/ScriptableObject, outputs are events and inputs are methods called by events. The tool served our purpose for the project very well and it seemed that this was a common problem for Unity devs so I asked the company that hired me to allow me to open-source it (and they said yes!)SmartData

Open-Sourcing it was definitely a great call. The reception of the tool was amazing and it saved many hours of development to other teams. It was the first time for me sharing something that is not hackatony code so it also felt great to know that it was helping many other people (also I have to say getting many GitHub stars feels good)! But most importantly it kept some pressure on me to keep improving the tool. Thanks to sharing the code I find the motivation to (among others):

  • Support more versions of Unity
  • Animate the edges so when an event fires a little circle travels through them
  • Make the graph nicer, even adding icons depending on the type of object
  • Make the window zoomable. Such an important and ridiculously difficult to implement feature!

I even got contacted by others developers asking to integrate/customise the tool for their own bigger frameworks. You can find the UnityEventVisualizer integrated in the SDDEventManager and a more advanced and beautiful version in the SmartData framework by the amazing Luke Thompson which I really encourage you to check out if you want to flex-out your architecture to the max!

Check the github repo for all the details: https://github.com/MephestoKhaan/UnityEventVisualizer