using UnityEngine;
using UnityEngine.UI;
public class Example : MonoBehaviour
{
[SerializeField]
private Button button;
void Start()
{
button.onClick.AddListener(RunThisTask);
}
void RunThisTask(){
//do something
}
}