Hide
ButtonAddOnClick

Add 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 funcName the callback function name

  • string buttonComp=null the button component name.

    If null, it'll try to get the button component by this order:

    1. the field itself
    2. get the Button component from the field itself
    3. get the Button component from the current target

    If it's not null, the search order will be:

    1. get the field of this name from current target
    2. 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!"); }

buttonaddonclick