With that you can start, stop, and resume coroutines.
Here’s an example I just slapped together that disables and re-enables the coroutine.
using UnityEngine;
using System.Collections;
using com.spacepuppy;
public class RPCDelegateTest : SPComponent {
private RadicalCoroutine _routine;
protected override void Awake()
{
base.Awake();
_routine = new RadicalCoroutine(this.Foo());
}
protected override void OnStartOrEnable()
{
base.OnStartOrEnable();
if (!_routine.Complete) _routine.Start(this);
}
private IEnumerable Foo()
{
Debug.Log("START");
yield return new WaitForSeconds(1.0f);
Debug.Log("Disabling!");
//this line here will automatically stop this coroutine
//but the RadicalCoroutine reference above will store the state of it
this.gameObject.SetActive(false);
com.spacepuppy.Timers.GameTimers.CreateGypsyTimer(2.0f, (t) =>
{
Debug.Log("Enabling!");
this.gameObject.SetActive(true);
});
yield return null;
Debug.Log("Resume...");
yield return new WaitForSeconds(1.0f);
Debug.Log("DONE!");
}
}