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
Instanceproperty. - Create its host GameObject, named
[CoroutineHost], and mark itDontDestroyOnLoad. - Remove duplicate components in
Awakeby destroying any new component when another instance already exists. - Start supplied
IEnumeratorroutines throughRun, which callsStartCoroutine.
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 anIEnumerator. The XML documentation names flow controllers, services, and managers as the intended callers. Those classes are not defined in this folder. - Unity. The
UnityEngineMonoBehaviour,GameObject,StartCoroutine,Destroy, andDontDestroyOnLoadAPIs.