How do I NOT play a sound on the first selected button.
Hi guys,
I'm struggling with my main menu. I figured out how to do the selection including sounds (works great), but I do NOT want to play a sound on the first selected button. I use an explicit navigation on my button and an event trigger (select). This is KEYBOARD INPUT only, NOT mouse!
I can't find any information on this other than an old post from someone with the same issue but no replies..
Any idea?
Answer by Marcus79 · Jun 16, 2021 at 08:52 AM
Thanks for the reply. That was my first thought as well, but that didn't work :( I think I need to use the UnityEngine.EventSystems namespace in order check if the button is selected. Also I need to implement an interface ISelectHandler.
I found a similar post: https://answers.unity.com/questions/921720/how-can-i-check-if-a-ui-button-is-selected.html
I hooked it up but the console is not spitting anything out. If I can figure this out then I could use a bool to bypass the first sound.
Thus far I have:
public void OnSelect(BaseEventData eventData)
{
Debug.Log(this.gameObject.name + " was selected");
}
but on which gameObject do I put this script (or reference)?
Never$$anonymous$$d, I figured it out. It was on the button itself of course! I AM SUCH AN IDIOT!! Sorry for wasting your time.. apologies.
Answer by lvskiprof · Jun 15, 2021 at 08:00 PM
It sounds like you need to have a boolean that is set to false by default and set to true after your explicit navigation event happens. Once it is true you play sounds, but when it is false you don't.
Your answer
Follow this Question
Related Questions
Selectable/Button not being selected 0 Answers
Unity The buttons do not catch the finger speed. 0 Answers
Creating a 2D sprite with Trigger Events? 2 Answers
button pressing the button next to it?! 2 Answers
Android UI push Multiple buttons Help 0 Answers