Extending the time of a yield WaitForSeconds()?

Is there a way to add time to a yield WaitForSeconds() after it has already started?

For example you have an ability that is supposed to last for 5 seconds but if you activate it a second time then 5 more seconds should be appended to the time it’s activated. Is there a way to do this or do I need to instead write code going through the game time?


function Ability(time : float)



yield WaitForSeconds(time);



No, there isn't. What you could do is build a logic using Time.time. Eg:

var waitUntil : float;
var isWaiting = false;

function Ability(time : float) {

    if(!isWaiting) {

        isWaiting = true;

        waitUntil = Time.time + time;

        while(Time.time < waitUntil)


        isWaiting = false;
    else {

        waitUntil += time;  


If Ability is called a second time before the first one finished, it only adds to the time it will wait to call DeactivateAbilityPower.