Support => NGUI 3 Support => Topic started by: Alayna on May 01, 2012, 05:21:32 PM
Title: How to Control AudioListener.Volume With NGUI Sliders
Post by: Alayna on May 01, 2012, 05:21:32 PM
I have been trying for a while to figure out what script I should attach to the NGUI Slider in order to make it control the overall volume. I have already looked for as many answers as I can on Unity Answers and the NGUI forms here and have so far had no luck. I would very much appreciate it if someone could share with me a script to perform this function, and maybe explain how it works. Thanks in advance!
Title: Re: How to Control AudioListener.Volume With NGUI Sliders
Post by: ArenMook on May 01, 2012, 08:22:43 PM
Assuming your audio source and listener is on the main camera (as is the case with all sounds coming from the UI), you could simply attach this script to your slider:
usingUnityEngine;
publicclass ControlVolume : MonoBehaviour
{
void OnSliderChange (float volume)
{
Camera.main.audio.volume= volume;
}
}
Title: Re: How to Control AudioListener.Volume With NGUI Sliders
Post by: Echo on November 29, 2012, 09:41:07 PM
That isn't working, did an NGUI update change this?
Title: Re: How to Control AudioListener.Volume With NGUI Sliders
Post by: ArenMook on November 30, 2012, 05:49:46 AM
Old post. Yes, modify NGUITools.soundVolume.
Title: Re: How to Control AudioListener.Volume With NGUI Sliders
Post by: ArenMook on November 30, 2012, 05:51:04 AM