Clickable Buttons and Sound Problem?

Hello All,

I am working on making a small menu system for a little project I am making. The idea being when the button is clicked I want it to make a sound then go to the scene corresponding to the Button.

Now, when I just had the button testing for an onClick() condition and playing a sound through a script it was fine fine, however when I put a condition underneath that to go to the correct scene the sound stopped playing. I am guessing that because the button was loading up a scene, it was overriding the scene trying to play the sound.

So is there anyway to overcome this and get the sound playing for the onClick that doesn’t blow out my mind or get too complicated?

To anyone who can help here is a big thankyou in advance.

Thankyou and Regards.

  • You could wait until the sound finishes playing before loading the scene, and do a fade out meanwhile.
  • You can also call DontDestroyOnLoad() on the GameObject with the AudioSource and destroy it automatically when it finishes playing the sound.

You can do that?!?