I have a grid of buttons all sharing same handler. Is there any way to get what button was clicked when the button calls back the handler? I know I can add a GameObject param to the OnClick event in the editor but this is a bit odd. Must I add this information in editor to be able to know what button was clicked? I expected this information was going to be passed by the button when it called-back the handler.
Alternatively you can consider adding 1 script to all your buttons instead, which should include:
private Button buttRef;
private void Awake()
buttRef = GetComponent<Button>();
private void Start()
if (buttRef != null) buttRef.onClick.AddListener(() =>
//do whatever you want here
And just add this script to prefab of your buttons or to each button, and you don’t need to do anything in the Inspector.