Author Topic: NGUI 2.1.6 UIButtonSound Issues?  (Read 8055 times)

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
NGUI 2.1.6 UIButtonSound Issues?
« on: September 15, 2012, 07:39:29 PM »
I just updated to 2.1.6 in my existing project (that was all working).

Now hitting an issue where some of the UIButton objects that also have UIButtonSound on them will not play their sound, and after clicking them, stop ALL sound from working. As in the game still runs, but audio is "muted" somehow.

Any known issues here?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 2.1.6 UIButtonSound Issues?
« Reply #1 on: September 16, 2012, 01:22:07 AM »
All the sounds NGUI plays goes through NGUITools.PlaySound. The only thing that changed recently was the addition of "source.priority = 255;".

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: NGUI 2.1.6 UIButtonSound Issues?
« Reply #2 on: September 16, 2012, 02:16:59 AM »
Seems like something has changed in the way NGUI associates with an audio listener? I have no idea - just guessing here.

I use one audio listener through the menu system and those button (with UIButtonSound) work okay. Once I get into the game though, that audio listener is destroyed and another one "takes over". At that point, UIButtonSound no longer plays on any of the GUI buttons.

Does that make any sense?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 2.1.6 UIButtonSound Issues?
« Reply #3 on: September 16, 2012, 03:19:48 AM »
You can only have one audio listener in the scene at a time. Check the console log for warnings.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: NGUI 2.1.6 UIButtonSound Issues?
« Reply #4 on: September 18, 2012, 08:03:05 AM »
Any other ideas on this? Basically, UIButtonSound works fine through my menu systems, credits screen, etc (all separate scenes). When I load into level 1 of the game, all the UIButtonSounds no longer play. Game audio still works fine. If I then enter another level (e.g. take the stairs down to level 2), the UIButtonSounds start working fine again. It's really baffling. It was working fine before updating.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 2.1.6 UIButtonSound Issues?
« Reply #5 on: September 18, 2012, 09:02:07 AM »
It might be an issue with when the sounds actually play. If you believe it worked before you can comment out that line I mentioned before and see if that helps. If it doesn't, then I suggest trying to figure out where the AudioSource is located. NGUI automatically creates an audio source on the main camera if one is not already present. Perhaps it's using an audio source which is somewhere else in the scene.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: NGUI 2.1.6 UIButtonSound Issues?
« Reply #6 on: September 18, 2012, 08:26:21 PM »
Yep - commenting out source.priority = 255; in NGUITool.cs has fixed the problem. Not sure why, but just happy it's working again :)

Thanks.

inewland53

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: NGUI 2.1.6 UIButtonSound Issues?
« Reply #7 on: June 21, 2013, 11:05:38 AM »
In my case, the audio listener was detecting a deactivated AudioListener attached to another camera. I fixed this like so...

NGUITools.cs - line ~86
  1. //mListener = GameObject.FindObjectOfType(typeof(AudioListener)) as AudioListener;
  2. mListener = Camera.mainCamera.GetComponent<AudioListener>();
  3.  

Maybe T can update a fix that filters out deactivated Audio Listeners...