Playing sounds when using GUI

Hi,
I’m been searching around for an answer - but I can’t seem to find one that fits the bill.

When a user interacts with a GUI element, be it a button, slider, checkbox etc I want a sound to play.
At present, I have the following script working:

protected bool Button(Rect rect, string text)
{
	bool result = GUI.Button (rect, text);
		
	if (result)
	{
		source.PlayOneShot (clickedClip);
    }
    return result;
}

This is in the parent class and all areas that use the GUI call this method to draw a button. This works…
But what about check-boxes, sliders and other GUI elements. What about adding a sound effect as the user types in a textbox?

After looking at numerous things such as Event triggers etc. I cannot find a simple solution that works.

I did not expect that having a noise playing when interacting with a GUI element to be so difficult, especially when practically every game I play has sound effects on buttons.

Any help will be greatly appreciated.

You can use Event to play sound clips.

Just get the current event and based on what type of event is fired you can play specific sound clip like if you want to play sound on user presssing a key then you can check for Event.isKey or EventType.KeyDown and play the key sound clip.

You can also work with EventType.MouseDrag for slider where in when mouse drag is fired just check if it is inside your slider and play the sound.