You understand everything.
P. S. I don’t need to set script enabled on click, I need to know how to realize it ONLY with script and where I should to attach it. There are no any code examples in docs.
P. P. S. UnityScript (JavaScript) only, please.
import UnityEngine.UI;
var myButton : Button;
function Start() {
myButton.onClick.AddListener( onClickFunction );
}
function onClickFunction() {
Debug.Log("Hello World");
}
Attach your button in the inspector!