Hey there!
Is there a nice way to measure the time while pressing a button?
Meaning: When I press and hold a button a "timer" should go off and if it the button is pressed long enough something happens.
I searched the forums already and only got some older postings where recording the time in OnPress and checking it in Update was suggested. A legit and good idea, but here's the thing:
When the button is pressed long enough there should "popup" another GUI-Window (Widget, Sprite etc.) with a label asking the Player something specific.
I wanted to achieve this with Coroutines and NGUI-Tween-Events. Coroutines don't work properly in Update() and I don't want to add Events every frame in Update() while the "timer" fulfills the condition.
void OnPress(bool pressed)
{
if(pressed)
{
// I know this won't work, but I add it anyways, so you get my idea:
timer += Time.deltatime;
if(timer >= x)
{
// Start Coroutines
// Do cool Eventstuff
}
}
}
Any suggestions?
