1
NGUI 3 Support / Volume Slider
« on: December 13, 2014, 05:39:03 AM »
I setup 3 volume sliders that work just fine. However if you were to move the volume slider for 'music' it would still effect the volume for 'sound'. I have two child gameobjects under MainCamera one for music the other sound, each one with a audio source.
- void Start () {
- UISlider slider = GetComponent<UISlider>();
- EventDelegate.Add(slider.onChange, masterVol);
- EventDelegate.Add(slider.onChange, soundVol);
- EventDelegate.Add(slider.onChange, musicVol);
- }
- // Update is called once per frame
- void Update () {
- }
- void masterVol()
- {
- GameObject.Find("Sound").audio.volume = +UISlider.current.value;
- GameObject.Find("Music").audio.volume = +UISlider.current.value;
- //Debug.Log("Sound volume: " + UISlider.current.value);
- }
- void soundVol()
- {
- GameObject.Find("Sound").audio.volume = +UISlider.current.value;
- }
- void musicVol()
- {
- GameObject.Find("Music").audio.volume = +UISlider.current.value;
- }
