Short Unity Tip: UnityEvents! (For Unity 4.6+)
Unity has a brand new, edgy, and super cool feature partly implemented called UnityEvents.
Decompiling the new Unity UI, we can see it being used for the new UI's Buttons as a means to invoke methods and pass in parameters.
To use the UnityEvent class, you'll need to add:
And... Thats it!
Firing the methods serialized from the
UnityEvent variable is as easy as
Note that there are a few limitations and you'll find that in complex matters with a number of parameters, it won't fare well.
Although its super helpful and easy to build upon!