Inspecting UI event handlers
22 Feb 2016Unity’s UI system lets components of GameObjects register event types they want to handle. It then forwards input events to the appropriate handler components. Keeping an overview of all those components is hard with the scene hierarchy window, because it contains so many objects. The UIEventBackend provides a single location for accessing all UI event handler components and their listeners. See it in action here.
How to use it
If you haven’t yet, install the RelationsInspector. Download the backend files from GitHub and put them into an Editor folder. Open the RelationsInspector through the Window menu, select UIEventBackend from the toobar dropdown and click the Show all scene events
button, to see all UI event handler components of the loaded scene.
The scene node is connected to all handler components, and those are connected to their listeners. By hovering over an arrow you can see what event a listener subscribes to. Hovering over a listener node shows details about the target object, the called method and the passed argument. Through the listener node’s context menu you can open the method’s source file, if it is available.
By dragging GameObjects into the window, you get only handlers that are children of those GameObjects. Through the backend toolbar you can choose how node selection should be handled:
- Select GameObject will select the GameObject of the handler or listener in all other Unity windows
- Select component will select the component of the handler or listener in all other Unity windows (nice for event editing)
- None leaves Unity’s selection unchanged and thus won’t effect other windows