- Home /
Question by
wpatel · Jun 26, 2019 at 09:57 PM ·
eventsystemevents
Getting the number of event handlers on an object and checking for null
Hello.
I am trying to create a test script to assure none of my UI elements have missing event handlers. I was originally use EventBase.GetPersistentEventCount() but it does not give back valid values.
Firstly, it does not hold any handlers added through script. So, Button.onlick.AddHandler() does not update the count. Only the ones added in the inspector do. Second, if you add an event handler through the editor but the delegate value is not assigned, it is still included in the event count.
Any ideas in how to tackle this. I don't mind using Reflection. I attempted it but I wasn't able to identify the right property to check.
Thanks in advance!
Comment