Author Topic: Toggling sounds on/off  (Read 8190 times)

Alessaint

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 67
    • View Profile
Toggling sounds on/off
« on: April 30, 2012, 07:37:38 AM »
Hi,

I was wondering what would be the easiest way of disabling the NGUI sounds if a user turns the sound off in application settings. By disabling all the UI Button sound components? Would it be possible to have a  method to call (say something like NGUITools.ToggleSounds( true ) ) that would allow to toggle ngui sounds on / off in general?

Thanks

Ales

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Toggling sounds on/off
« Reply #1 on: April 30, 2012, 07:43:21 AM »
Only one function is used to play NGUI sounds -- NGUITools.PlaySound. Just modify it to take your volume settings into account.

Alessaint

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 67
    • View Profile
Re: Toggling sounds on/off
« Reply #2 on: April 30, 2012, 07:54:29 AM »
Great, thanks a lot for the quick reply!

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Toggling sounds on/off
« Reply #3 on: May 01, 2012, 09:09:38 AM »
AudioListener.volume = 0f will turn of all sounds, you can do this from your settings. PlaySound will still play the sound, but the volume will be 0 (silent).