Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Adding Events Similar to the ButtonClickedEvent

Discussion in 'UGUI & TextMesh Pro' started by craigp, Aug 20, 2014.

  1. craigp

    craigp

    Joined:
    Aug 10, 2012
    Posts:
    7
    I like the serializable delegates that the UI button uses. I'd like to add them to my own scripts, with the same inspector system if possible. Not a click response - just general event handling.

    I'm having a hard time tracking down any tutorials about this. Normal C# delegates and events don't show up in the inspector, so it's not integrated that way, as far as I can tell.

    Anybody know anything?

    I've included a screenshot of the button's event system, if I wasn't clear about the functionality I'd like to add to my scripts.
     

    Attached Files:

  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,158
    Hi, if you check the offline scripting documentation there should be a c# example of how to do this :) Search for the class "UnityEvent".
     
    shkar-noori likes this.
  3. craigp

    craigp

    Joined:
    Aug 10, 2012
    Posts:
    7
    Ah, it's a UnityEvent. Thanks! I think that's all I needed!

    ... Although I don't see any C# examples after all. Still, I think I can figure it out.

    ... Yup, works like a charm!

    Thanks for the fast response, Tim. And good work by the Unity devs on this update!
     
    Last edited: Aug 20, 2014
unityunity