How do you script volume control for music and sfx buses


(Jeanelle M) #1

I have my music and sfx on two separate buses in fmod. I want to be able to have the player change the volume settings for these via the pause menu in my game. How would I go about scripting that (C#)?

In trying to solve my own problem I got as far as this link, but I don’t know how or where to put it in my script. http://www.fmod.org/documentation/#content/generated/FMOD_Studio_Bus_SetFaderLevel.html

Thanks in advance guys.


(Cameron Baron) #2

It is fairly easy, once you have a reference to the bus you can then adjust the fader level:

 string masterBusString = "Bus:/";
 FMOD.Studio.Bus masterBus;
 
 masterBus = FMODUnity.RuntimeManager.GetBus(masterBusString);
 masterBus.setFaderLevel(float);
 masterBus.getFaderLevel(out float);

This fader level is relative to the fader level set in FMOD Studio.
Then it is up to as to how you want to expose/control it.


(Jeanelle M) #3

Ah ok, that makes sense. Thanks!


(David Hunter) #4

Thanks! This really helped me too!


(Pablo Sorribes Bernhard) #5

Same here! I wonder why they don’t just put an example like this in the Documentation.