Search Unity

Audio Muted AudioSource still playing

Discussion in 'Audio & Video' started by deLord, Aug 24, 2017.

  1. deLord

    deLord

    Joined:
    Oct 11, 2014
    Posts:
    257
    Hey guys

    I recently started implementing sounds and music into my game and now some behavior is totally different from what I expect.

    I have a GO called "Sfx Audio Source" with an AudioSource Component outputting to my SFX mixer group.
    So far so good; my music level is different to my sfx level.

    But, when I mute this AudioSource via script, then still the mixer group is playing the sound. How can that be? I just use
    Code (CSharp):
    1. sfxAudioSrc.mute = true;
    Muting it by hand leads to the expected behavior. Also, changing the volume via script led to the same behavior, i.e. still playing the sounds.

    Edit: OK, I got why it is playing the sounds, because I am unmuting after the dialog has played. So, what I want to achieve is rather just for 1 frame to not play any sounds. Seems muting is the wrong option because unmuting in the same frame leads to playing the sounds, just skipping the very first frame of it.
    Is there a script-friendly standard way to temporarily SKIP sounds to be played?

    The way I came up with is to ask if(mute) when the sound should be played.

    I would maybe delete this thread but I don't know how :)
     
    Last edited: Aug 24, 2017
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,629
  3. deLord

    deLord

    Joined:
    Oct 11, 2014
    Posts:
    257
    I think not, since the unpause will happen 1 frame after or even at the same time as the sounds are being played.
    But mb I got it wrong; I will check later
     
    Last edited: Aug 26, 2017
unityunity