Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - neccta

Pages: [1]
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.

  1.         void Start () {
  2.         UISlider slider = GetComponent<UISlider>();
  3.         EventDelegate.Add(slider.onChange, masterVol);
  4.         EventDelegate.Add(slider.onChange, soundVol);
  5.         EventDelegate.Add(slider.onChange, musicVol);
  6.         }
  7.        
  8.         // Update is called once per frame
  9.         void Update () {
  10.        
  11.         }
  12.     void masterVol()
  13.     {
  14.         GameObject.Find("Sound").audio.volume = +UISlider.current.value;
  15.         GameObject.Find("Music").audio.volume = +UISlider.current.value;
  16.         //Debug.Log("Sound volume: " + UISlider.current.value);
  17.     }
  18.     void soundVol()
  19.     {
  20.         GameObject.Find("Sound").audio.volume = +UISlider.current.value;
  21.     }
  22.     void musicVol()
  23.     {
  24.         GameObject.Find("Music").audio.volume = +UISlider.current.value;
  25.     }

Pages: [1]