Navigating menu with both keyboard and mouse issue

So I have a sound effect that plays when the user hovers over a button with the mouse. The same sound effect also plays when the user uses the keyboard to navigate through the menu buttons and this is triggered when the button is selected.

I have a separate sound effect that plays when the user actually clicks / activates the button.

Let’s say the user moves the mouse over a button, it will play the onmouseenter sound correctly. Next we click the button, however since clicking both triggers the onclick trigger AS WELL AS the select trigger, we hear 2 sounds. I only want to hear the onclick sound in this case. I need the select event trigger to cater for keyboard users so I can’t simply delete it.

I have about 100 buttons like this so would prefer something that wouldn’t involve changing the inspector since then I’d need to do that 100 times. It would be preferable to just be able to change something in the script. However if that’s not possible open to ideas of changing the inspector.

Any advice appreciated. Thanks.

In OnMouseEnter you could add a check like if (!Input.GetMouseButton(0)). Only do the select sound if the mouse button is not pressed.

1 Like

This worked.Thanks!