using UnityEngine.UI; public class ButtonScript : MonoBehaviour { public Button btn; void Awake() { btn.onClick.AddListener(btnClicked); } void btnClicked() { Debug.Log("Button clicked"); } }