Author Topic: Block events after button click  (Read 2408 times)

syslord2k2

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Block events after button click
« on: April 02, 2014, 04:10:32 AM »
Hi everybody,

i am sorry if this question was already answered but i didn't find it with the search function.
So i have these buttons that play a tween and then disappear but i don't want the user to be able to press another button while the tween is playing.
Is there a possibility to tell ngui to not process touch events?

Best regards

Michael

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: Block events after button click
« Reply #1 on: April 02, 2014, 04:31:30 AM »
You can have a collider that covers these buttons and enable it when you don't want them to be pressed and disable it when the tweens have finished.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Block events after button click
« Reply #2 on: April 02, 2014, 04:31:55 PM »
ALT+SHIFT+W to add a widget. ALT+SHIFT+C to give it a collider. Resize to cover the area you want to not respond to events. Adjust the depth like any other widget.

syslord2k2

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Block events after button click
« Reply #3 on: April 03, 2014, 02:56:37 AM »
Hi guys,

thanks for the responses, i had that idea myself but it seemed too much effort since i had to do extra colliders for every button and activate and deactivate  components to handle them.

I ended up adding a shouldProcessEvents public bool to the UICamera that would return the update function in line 963 if it was false and created a component that i added to every button that would set it to false, wait for a given amount of seconds and then set it to true again.

Works like a charm but of course i have to be really careful with NGUI Updates now :)