Author Topic: [solved] UISounds overlapping  (Read 2823 times)

yo_milo

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 2
  • Posts: 36
    • View Profile
[solved] UISounds overlapping
« on: August 19, 2014, 05:32:18 PM »
Hello...

I have this problem, that, when I spam clicking a button, the sounds it produces overlap; this is very annoying because I have sounds that are up to 4 seconds long.

I was looking through the code, and I realized that at the end, UIPlayButton calls NGUITools.PlaySound(), and it does a PlayOneShot(Audioclip, volume).
If I want to fix this sound spamming problem, what approach would you recommend me? (or would you do it?)


Because, one thing I could do, is instead of using the NGUI's scripts, I could just have a "Sound manager" with an Audiosource, and just check if the Audiosource is not playing, and if it not, it can play a new sound... But I was hoping there was a "NGUI" based solution for my problem, because otherwise I would have to restructure a few things...

As I told you, I know a few ways around it, but Ideally, It would love you have an NGUI based solution...
« Last Edit: August 20, 2014, 05:24:23 PM by yo_milo »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISounds overlapping
« Reply #1 on: August 20, 2014, 03:09:02 PM »
Don't use UIPlaySound if you want some other logic than PlayOneShot. Do your own logic that will check to see if the sound finished playing or not.

yo_milo

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 2
  • Posts: 36
    • View Profile
Re: UISounds overlapping
« Reply #2 on: August 20, 2014, 05:24:05 PM »
I figured I would have to do this... Well, worth the shot... :) Thanks Aren...

By the way... Do you want to play a match of Starlink sometime?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [solved] UISounds overlapping
« Reply #3 on: August 20, 2014, 05:59:53 PM »
Coop or competitive? :)

yo_milo

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 2
  • Posts: 36
    • View Profile
Re: [solved] UISounds overlapping
« Reply #4 on: October 13, 2014, 05:27:54 PM »
Competitive... I gotta put my skills to the test...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [solved] UISounds overlapping
« Reply #5 on: October 14, 2014, 01:50:10 PM »
I haven't played it in a while... but Windward is moving forward quite well!

yo_milo

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 2
  • Posts: 36
    • View Profile
Re: [solved] UISounds overlapping
« Reply #6 on: October 16, 2014, 11:01:39 PM »
I assume... You seem to know very well what you are doing...


I might get early access with my next paycheck....