Shortcut for wrapping functions inside a simple IEnumertor?

I often use coroutines just for delaying a function til the next frame or delay it by 1 sec. But I’ll have to place a block of IEnumerator into the script, impairing its readability (i know you can hide and collapse it).

So is there a shorthand code ofor such IEnumertor/coroutines?

Like instead of “StartCoroutine(MyIEnum()) + wrapping MyFunc inside MyEnum;”, you write “MyFunc(WaitForSeconds(5f));”

Something like this?

I use my CallAfterDelay class for delayed action.

See usage notes at bottom below gist code.

1 Like

Thank you so much! Precisely what I’m looking for.

Though is there a performance issue if I’m running say like 20 of this script at once, since it’s adding deltatime per frame?

Thanks anyway, my codes will be much cleaner.