Author Topic: NGUI button sounds no longer play independently of main AudioListener volume?  (Read 5029 times)

ett.ufo

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Everything was working perfectly before upgrading to Unity 4.3 and NGUI 3.0.7 ( from 4.2 and 3.0.2)

Now, gui sounds are no longer played (with other than 0 volume) when AudioListener.volume is set to 0.

According to this post, it still should be played with its own NGUI volume setting:
http://www.tasharen.com/forum/index.php?topic=5273.0

Is the functionality broken broken in 3.0.7?

Thanks
/Ufot

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
NGUITools.PlaySound finds the audio listener and plays the sound through it. This part of code has not changed since NGUI 1.5 or so. Furthermore, AudioListeners have no volume, so I am not sure what you are referring to. Do you mean AudioSource.volume? NGUI adds the AudioSource to the main camera if there isn't one already present. It won't alter the volume setting you set.

ett.ufo

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
My god, you're fast...

But, hmm, now I'm not understanding you. Sorry.

I am led to believe that AudioListener indeed has a volume:
http://docs.unity3d.com/Documentation/ScriptReference/AudioListener-volume.html

Also see your answer in the other post where you explain (to my understanding) that AudioListener.volume and NGUITools.volume are two different settings.
http://www.tasharen.com/forum/index.php?topic=5273.0

My setup that was working before the upgrade was to set AudioListener.volume (and timescale) to 0 when in menus and let NGUI's very handy independent timescale and volume handle the interface.

I know it maybe was a bit lazy approach, but it worked.



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Hmm. Actually I was not even aware of that static property. In that post I was talking about AudioSource.volume.

I believe AudioListener.volume is the global sound, so if it didn't affect NGUI sounds before then it was bugged and likely fixed in a recent update to Unity itself.

ett.ufo

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Hmm. Actually I was not even aware of that static property. In that post I was talking about AudioSource.volume.

I believe AudioListener.volume is the global sound, so if it didn't affect NGUI sounds before then it was bugged and likely fixed in a recent update to Unity itself.

Yes, I dove into the NGUI code while debugging and compared Unity 4.2 to 4.3 and can confirm that AudioListener.volume == 0 does not affect added audio source volume (added by NGUI) in 4.2 but it indeed does in 4.3...
Since it does affect already playing sounds I guess they had missed to apply the master volume to sounds dynamically added later (seems a bit strange, but who knows).

Hehe, funny, I actually used that Unity bug thinking it was some kind of "automagical" feature of NGUI to separate the GUI from the game.

"It's not a bug it's a feature" FTW

Thank you for your quick responses and for a great product!
/ufot