Author Topic: Limit how often a button is clicked...  (Read 1966 times)

Rooster

  • Guest
Limit how often a button is clicked...
« on: October 19, 2013, 03:34:24 AM »
As the title says, I was wondering if there is a way to limit how fast a player can click a ui button.  My ngui button works fine, but my gameplay mechanics go out the window if I sit there and spam that button as fast as I can, for as long as it takes.  I thought maybe a minimum time between clicks would slow the whole thing down. Thanks.

macy

  • TNP Alpha
  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 8
    • View Profile
Re: Limit how often a button is clicked...
« Reply #1 on: October 19, 2013, 03:15:46 PM »
You can use a timer, please take a look at an example here:
http://answers.unity3d.com/questions/225213/c-countdown-timer.html

Or you can use StartCoroutine by turn a boolean to true or false
http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.StartCoroutine.html

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Limit how often a button is clicked...
« Reply #2 on: October 19, 2013, 05:34:06 PM »
Depends on the design, of course, but you could consider hiding the button while it's unclickable. Make it unclickable by just removing it, and reactivating with a Coroutine or in an update loop.