If I put all my SFX in one mixer channel how can I control the channel with a slider in unity?


(Jack) #1

In my game I have a menu an audio section and inside of that is a button to toggle audio on and off and a slider to adjust the level of the sound effects. Ideally I would like 100% on the slider to be at 0dB but I can’t wrap my head around how to script it. Any help please?

Edit: I’ve created a snapshot called SFXvol and a corresponding event to house it. Inside the snapshot it says I can automate the volume fader on the sfx channel but where do I go form here? I know how to connect the parameter to the slider in unity.


(Cameron Baron) #2

You could use a snapshot but adjusting the volume of the corresponding buses would be easier, especially when using the Unity GUI Sliders.

FMOD.Studio.Bus sfxBus;
Slider sfxSlider;

sfxBus = FMODUnity.RuntimeManager.GetBus(busName);
sfxBus.getFaderLevel/getVolume(out volume); // Depending on the version of FMOD
sxfSlider.value = volume;

Then you can setup functions for when the slider value changes.

void OnSFXValueChange()
{
volume = sfxSlider.value;
sfxBus.setFaderLever/setVolume(volume); // Depending on the version of FMOD
}


(Jack) #3

Thanks for the help.
This is probably one of those things that will seem super easy to me in the near future but i’m struggling a little to understand at the moment.

first off,
sfxBus = FMODUnity.RuntimeManager.GetBus(busName);

I’m guessing this section all goes inside the awake/start function and where it says ‘(busname)’ I’m not sure what to put. Is it literally like calling a parameter in fmod and writing what I’ve called my bus in single quote marks?


(Cameron Baron) #4

Yep that’s exactly how you could do it.

The bus naming convention is similar to events and banks as well. (eg. “bus:/” is the master bus)


(Jack) #5

I’ve tried some different versions of what you have said and can’t figure it out. I’m getting these as errors, any ideas?


(Cameron Baron) #6

GetBus() is expecting a string.
You will either need to use a string variable or use “bus:/SFX” (with quotation marks).


(Jack) #7

I’m still getting these errors, any ideas?
http://imgur.com/a/ptbhQ