|
Post by tarenar on Aug 12, 2015 1:18:59 GMT
how do i globally change the volume of looping sounds that are already playing?
I have a settings screen where I'm lowering the volume. However after lowering the volume to 0, previously looping sound effects still play at the same volume
I've tried grabbing all playing sound variations and lowering their volume like so:
List <GameObject> soundObjects = MasterAudio.GetAllPlayingVariationsInBus(Audio.Bus.SFX); foreach(GameObject soundObject in soundObjects)
{
SoundGroupVariation sgv = soundObject.GetComponent<SoundGroupVariation>();
sgv.AdjustVolume(newVolume);
} But it only changes the volume of newly played looping sounds, not the one that's already being played.
|
|
|
Post by DarkTonic Dev on Aug 12, 2015 1:30:41 GMT
Normally you would just change ALL sound effect volumes by using this:
MasterAudio.MasterVolumeLevel = .5f;
That changes the output of all buses. Or you can set the volume of the bus. Or you can set the volume of the Sound Group. Those would all be preferable to the code you used. Does one of those work for you?
|
|
|
Post by tarenar on Aug 13, 2015 20:20:02 GMT
Changing MasterAudio.MasterVolumeLevel does work, however I can't simply change the master volume because I have multiple buses: SFX, Announcer, UI. I have multiple volume sliders for each bus.
I do also set the bus' volume directly like so:
MasterAudio.SetBusVolumeByName(Audio.Bus.SFX, value); However, as mentioned before, previously looping sounds continue to play at their previous volume even after setting them to a new volume. Newly played looping sounds respect the new volume. Is this as designed or a bug?
Setting the sound group's volume directly does work:
MasterAudio.SetGroupVolume("loopingSound", value); However I would have to manually type in all the looping sound names I think may possibly play.
Is there any way to get all the names of currently playing sounds in a bus? That way I can iterate through them and set their volumes. Something like:
List <string> soundStrings = MasterAudio.GetAllPlayingSoundStringsInBus(Audio.Bus.SFX);
foreach(string soundString in soundStrings )
{
MasterAudio.SetGroupVolume(soundString, value); }
|
|
|
Post by DarkTonic Dev on Aug 14, 2015 5:00:32 GMT
I just did a test on the example Scene #1 and SetBusVolumeVolumeByName works fine for already looping sounds.
If it's not working for you, you'll need to send me an example project showing the bug you're seeing.
Note that if you have things looping by checking "play on awake" in the Audio Source instead, that is not supported and Master Audio will log a message to the Console telling you what to do instead for the same result.
There's also the command MasterAudio.GetAllPlayingVariationsInBus which gets what you want for the last question. Although it seems to be returning game objects right now. I've changed that to return Variation objects instead for the next version.
|
|