I'm trying to create the same functionality that occurs when you are working with a button in uGui in Unity. I know that I have to create a custom inspector, but i'm not sure where to go from there.

Essentially the functionality allows you to drag and drop a script to it's on click portion in the inspector, and then it gives you a list of functions for that script to select. This may sound a little confusing, so here are a few pictures demonstrating the functionality i'm trying to replicate.





As you can see above the functionality allows you to drag in a script, select a function to link, and do this for as many or as little scripts as you want by pressing the + or - buttons on the bottom right.

Thanks for any help in advance!


1 Answer 1


You need to use UnityEvents to make use of such functionality. Derive a class from UnityEvent and then then declare a public member:

public class MyEvent : UnityEvent<int> {}

public MyEvent onClick;

This will show up as the custom inspector widget you want. To send the event you do something like this:


Take look at this tutorial I made on a Rating Bar widget that uses Unity Events


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .