docs
Systems
Execution
CoroutineSystem
Key Components

Components

CoroutineHost

CoroutineHost is the only class defined in this system. It is a sealed MonoBehaviour that serves as the coroutine execution context for non-MonoBehaviour code.

Responsibilities

  • Hold the application-wide instance in a static field and create it on first access through the Instance property.
  • Create its host GameObject, named [CoroutineHost], and mark it DontDestroyOnLoad.
  • Remove duplicate components in Awake by destroying any new component when another instance already exists.
  • Start supplied IEnumerator routines through Run, which calls StartCoroutine.

Interaction with other classes

The source defines no interfaces, handler classes, listener classes, events, or data classes in this system. The CoroutineHost interacts only with the following:

  • Callers. Any code that calls CoroutineHost.Instance.Run(...) with an IEnumerator. The XML documentation names flow controllers, services, and managers as the intended callers. Those classes are not defined in this folder.
  • Unity. The UnityEngine MonoBehaviour, GameObject, StartCoroutine, Destroy, and DontDestroyOnLoad APIs.