Author Topic: PlaySound bug  (Read 3680 times)

ddfire

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
PlaySound bug
« on: November 19, 2012, 05:07:35 PM »
hi
NGUITools.Playsound(...) has a bug... if you disable the first audiolistener, and active a second one, since mListener is static will not detect the change and will trow:
Can not play a disabled audio source
UnityEngine.AudioSource:PlayOneShot(AudioClip, Single)
NGUITools:PlaySound(AudioClip, Single, Single) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:100)
UIButtonSound:OnClick() (at Assets/NGUI/Scripts/Interaction/UIButtonSound.cs:49)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
UICamera:Notify(GameObject, String, Object) (at Assets/NGUI/Scripts/UI/UICamera.cs:546)
UICamera:ProcessTouch(Boolean, Boolean) (at Assets/NGUI/Scripts/UI/UICamera.cs:1014)
UICamera:ProcessMouse() (at Assets/NGUI/Scripts/UI/UICamera.cs:796)
UICamera:Update() (at Assets/NGUI/Scripts/UI/UICamera.cs:654)

to reproduce play a sound, disable the audio listener, enable other one, try to play a sound again.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: PlaySound bug
« Reply #1 on: November 19, 2012, 05:11:14 PM »
More than one audio listener in the scene is an error that Unity will happily inform you about.

Just don't do it. If you want to have an audio listener move from one camera to another, make it separate. Don't attach it to your camera. Simply always make it set its position to the current camera in LateUpdate.

ddfire

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
Re: PlaySound bug
« Reply #2 on: November 20, 2012, 11:54:29 AM »
cool, thanks!