ButtonAddOnClickAdd a callback to a button's onClick event. Note this at this point does only supports callback with no arguments.
Note: SaintsEditor has a more powerful OnButtonClick. If you have SaintsEditor enabled, it's recommended to use OnButtonClick instead.
-
string funcNamethe callback function name -
string buttonComp=nullthe button component name.If null, it'll try to get the button component by this order:
- the field itself
- get the
Buttoncomponent from the field itself - get the
Buttoncomponent from the current target
If it's not null, the search order will be:
- get the field of this name from current target
- call a function of this name from current target
using SaintsField; [GetComponent, ButtonAddOnClick(nameof(OnClick))] public Button button; private void OnClick() { Debug.Log("Button clicked!"); }
