public static void SyncWait(IEnumerator runner) { var coroutine = new CoRoutine(runner); while (coroutine.Pump()) { } }
public static T SyncWaitGet <T>(IEnumerator runner) { var coroutine = new CoRoutine(runner); while (coroutine.Pump()) { } return((T)coroutine.ReturnValue); }
public static void SyncWaitWithTimeout(IEnumerator runner, float timeout) { var startTime = DateTime.UtcNow; var coroutine = new CoRoutine(runner); while (coroutine.Pump()) { if ((DateTime.UtcNow - startTime).TotalSeconds > timeout) { throw new CoRoutineTimeoutException(); } } }
public static IEnumerator <T> Wrap <T>(IEnumerator runner) { var coroutine = new CoRoutine(runner); while (coroutine.Pump()) { yield return(default(T)); } if (coroutine.ReturnValue != null) { Assert.That(coroutine.ReturnValue.GetType().DerivesFromOrEqual <T>(), "Unexpected type returned from coroutine! Expected '{0}' and found '{1}'", typeof(T).Name, coroutine.ReturnValue.GetType().Name); } yield return((T)coroutine.ReturnValue); }