Hey, were throwing together a 2D game, and were wondering about how to be able to change the volume of the entire game from a slider in the main menu? i’ve found some coding to be able to attach the values to a slider for single values (i.e., just the volume from the main music, or just the volume for a single effect), but is it possible to change the volume of everything from a slider in the main menu, and have these changes persist between scenes?
bump
You could use a class to hold the volume, and a monobehaviour to set volumes on start
class AudioSettingsContainer {
public static float audioVolume = 1;
}
//SEPERATE FILE;
class AudioSceneSetter {
void Start(){
AudioSource[] sources = FindObjectsOfType(typeof(AudioSource)) as AudioSource[];
foreach (AudioSource srce in sources) {
srce.volume = audioVolume;
}
}
}