Class CoroutineHelper
Provides a singleton UnityEngine.GameObject and UnityEngine.MonoBehaviour in the scene specifically for running coroutines. This helper is particularly useful for static classes or non-UnityEngine.MonoBehaviour objects that require coroutine-driven logic without needing to create their own UnityEngine.GameObject.
Inherited Members
Namespace: TriLibCore
Assembly: Assembly-CSharp.dll
Syntax
public class CoroutineHelper : MonoBehaviour
Properties
Instance
Retrieves the singleton instance of the CoroutineHelper. If no instance exists, one is automatically created in the scene with the name "Coroutine Helper".
Declaration
public static CoroutineHelper Instance { get; }
Property Value
Type | Description |
---|---|
CoroutineHelper |
Remarks
The created UnityEngine.GameObject is marked with UnityEngine.HideFlags.DontSave, which generally prevents it from persisting in serialized scenes.
Methods
RunMethod(IEnumerator)
Synchronously executes the provided IEnumerator until it completes. Unlike StartCoroutine(string), this method does not run asynchronously; it blocks until the iterator finishes.
Declaration
public static void RunMethod(IEnumerator enumerator)
Parameters
Type | Name | Description |
---|---|---|
IEnumerator | enumerator | The IEnumerator to execute step by step. |
Remarks
Because this method runs synchronously, it can be used in cases where you need
to process an iterator without yielding control back to Unity’s main loop.
Note that any calls to yield return
in the enumerator won’t cause
asynchronous delays.