Playing a sound on all button presses?

Hello,

I know I can add a sound to a button being pressed, but I was wondering if I could set some global rule that whenever a button is pressed, it plays the same sound. Just want to see if I can do this without having to go to every single button throughout the whole scene and add a sound manually.

Thank you

Hi @shapirog.

I wrote a comment too, but here is one solution;

void Start () 
{
	buttons = GameObject.FindObjectsOfType<Button>();
	
	foreach (var b in buttons)	{		
		UnityAction l = delegate { OnClick(); };
		b.onClick.AddListener(l);
	}
}

void OnClick()
{
	Debug.Log("Click!");
}