Coroutines class
A mod's coroutines: methods that run across multiple frames on the game's main thread, with identical behavior on Mono and IL2CPP. A coroutine is an iterator method; each yield return specifies when it resumes:
nullorWait.NextFrame: in the next frame, afterUpdateWait.Seconds,Wait.RealSeconds,Wait.Frames,Wait.Until,Wait.While,Wait.FixedUpdate,Wait.LateUpdate- another iterator: after that iterator has run to completion
- a
CoroutineHandle: after that coroutine ends; aTask: after the task completes - Unity yield instructions:
WaitForSeconds,WaitForFixedUpdate,WaitForEndOfFrame(treated as LateUpdate),WaitUntil,WaitWhileand otherCustomYieldInstructiontypes, andAsyncOperation
An exception stops the coroutine and is logged under the mod's ID.
csharp
public sealed class CoroutinesProperties
Count
csharp
public int Count { get; }The number of this mod's running coroutines.
Methods
Start(IEnumerator)
csharp
public CoroutineHandle Start(IEnumerator routine);Starts a coroutine. When called on the main thread, the coroutine immediately runs until its first yield, as with Unity's StartCoroutine. When called from another thread, its first step runs on the main thread in the next frame.
Stop(CoroutineHandle)
csharp
public void Stop(CoroutineHandle coroutine);Stops a coroutine before its next step. Has no effect if the coroutine has already ended.
StopAll()
csharp
public void StopAll();Stops all coroutines started by this mod.