Search Unity

Audio Can I turn off each audio sources individually

Discussion in 'Audio & Video' started by wowcrazyguy, Dec 31, 2018.

  1. wowcrazyguy

    wowcrazyguy

    Joined:
    Sep 24, 2018
    Posts:
    49
    Code (CSharp):
    1.  
    Hi guys,

    Please refer to below codes, I have created prefabs. if (isRifleSold == 1), my bullet is turn on so does my bullet sound effect.

    I have created two bullets' audio sources. One is audioakBulletSour. The other one is audiosour.

    I noticed that even if I only turn off one audio source. It actually results to disable all other sound effects including those with the different audio sources.

    Does anyone knows how to solve this.

    if (isRifleSold == 1)
    {

    aKbullet.SetActive(true);
    soundManager.audioakBulletSour.enabled = true;



    }
    else
    {

    soundManager.audioakBulletSour.enabled = false;
    aKbullet.SetActive(false);
    }


    if (isRealPistolSold == 1)
    {

    soundManager.audiosour.enabled = true;
    desertEagleBullet.SetActive(true);


    }
    else
    {
    soundManager.audiosour.enabled = false;
    desertEagleBullet.SetActive(false);
    }