Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Rooster on October 19, 2013, 03:34:24 AM

Title: Limit how often a button is clicked...
Post by: Rooster 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.
Title: Re: Limit how often a button is clicked...
Post by: macy 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
Title: Re: Limit how often a button is clicked...
Post by: Nicki 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.