- Home /
The question is answered, right answer was accepted
Controlling Master Volume with one slider?
I want to control all the volume in my game with one slider and have the sound stay that volume throughout all scenes, I've written a script but the volume never changes..?
public Slider VolumeSlider;
float masterVolume = 0.0f;
public void Example() {
masterVolume = VolumeSlider.value;
AudioListener.volume = masterVolume;
}
Answer by CodewithFin · Apr 15, 2016 at 11:05 PM
For anyone who's looking at this in the future, here's the code. :D
public void AdjustVolume (float newVolume) {
AudioListener.volume = newVolume;
}
It's work but dont save value when i back scene $$anonymous$$ain menu
where do you put that script? in the audio source or in the slider?
you can add this scripts to any object. Just make sure you select the correct slider you wanna use in the inspector
Your answer
Follow this Question
Related Questions
Music play throughout all scenes? 1 Answer
Multiple Cars not working 1 Answer
Need help with my slider 3 Answers
Getting weird effects from audio clip 1 Answer
Change sound dependent on slider? 1 Answer