Search Unity

Example of setting up a button OnClick event via scripting?

Discussion in 'UGUI & TextMesh Pro' started by TimBur, Sep 24, 2014.

  1. TimBur

    TimBur

    Joined:
    Jan 17, 2013
    Posts:
    35
    The tutorials do a good job of showing how to use the inspector to make a button call arbitrary functions on an OnClick event. I figure there must be a way to do the same thing via scripting - to give a button a list of functions to call when it is clicked. However, I'm getting lost in the documentation:
    http://docs.unity3d.com/460/Documentation/ScriptReference/Events.UnityEventTools.html
    file:///C:/Program%20Files%20(x86)/Unity_4.6.0b17/Editor/Data/Documentation/html/en/ScriptReference/UI.Button.ButtonClickedEvent.html

    Could anyone point me to a relevant example or tutorial? Something with C# code that deals with button event handling?