Skip to content

Coroutine

namespace Griff.Runtime;
public sealed class Coroutine

A sequence that runs over several frames, started with a behavior’s StartCoroutine or StartCoroutine. It runs right away up to its first yield return, then picks up again once what it yielded is done:

  • null: the next frame.
  • Wait(seconds) (or just a number of seconds): that much game time.
  • WaitUntil(() => ...) and WaitWhile(() => ...): a condition, checked every frame.
  • A Tween, GameTimer or another Coroutine: when it finishes.
  • Another IEnumerator method: runs it to the end first, like calling it. Like timers, coroutines run on game time, so they slow down with Scale and stop while the game is paused.
public bool IsRunning { get; }

False once the coroutine has finished or been stopped.

public Entity? OwnerEntity { get; }

The entity whose removal stops this coroutine, if any.

public void Stop()