Coroutine or While loop that you can reset/add time too?
Hello,
So I have some text that displays the current amount of points gained which then is made inactive after X seconds. Basically, gaining points enables a canvas element and starts a coroutine that disables it after X time.
What I want is that the 2 seconds of display time is reset every time the the more points function is called during those 2 seconds.
So you gain 500 points, then after 1.5 sec you gain another 500 points, the score of 1000 then is displayed for 2 seconds. What seems to be the case right now is that the score of 1000 is displayed for only .5 sec - as far as I can tell.
It seems you can't add additional time to a coroutine that's already active but I found some stuff from 2011 ( http://answers.unity3d.com/questions/197259/extending-the-time-of-a-yield-waitforseconds.html ) that maybe has the answer, the only problem is that this is super old code and causes errors.
Does anyone know how I might go about doing this? The language is C#.
I would still settle so that each call of gaining points simply adds to the remaining display time rather than resetting it. Resetting it would be preferable.
Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220612122439im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Coroutine, while, and Waitforseconds 1 Answer
Click two buttons at the same time 0 Answers
[Solved]Cant Find loop that freezes Unity 2 Answers
Checking Internet inside a Coroutine 0 Answers
StopCoroutine() Not Working 2 Answers