Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Clickable Buttons and Sound Problem?

Discussion in 'Editor & General Support' started by CelticKnight, Mar 29, 2018.

  1. CelticKnight

    CelticKnight

    Joined:
    Jan 12, 2015
    Posts:
    378
    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.
     
  2. PacoChan

    PacoChan

    Joined:
    May 28, 2015
    Posts:
    44
    • 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.
     
  3. CelticKnight

    CelticKnight

    Joined:
    Jan 12, 2015
    Posts:
    378
    You can do that?!?