public IEnumerator Run() { while (true) { var topWorker = processStack.Peek(); bool isDone; try { isDone = !topWorker.MoveNext(); } catch (Exception e) { // The IEnumerators we have in the process stack do not tell us the // actual names of the coroutine methods but it does tell us the objects // that the IEnumerators are associated with, so we can at least try // adding that to the exception output var objectTrace = GenerateObjectTrace(processStack); if (objectTrace.Any()) { awaiter.Complete( default(T), new Exception( GenerateObjectTraceMessage(objectTrace), e)); } else { awaiter.Complete(default(T), e); } yield break; } if (isDone) { processStack.Pop(); if (processStack.Count == 0) { awaiter.Complete((T)topWorker.Current, null); yield break; } } // We could just yield return nested IEnumerator's here but we choose to do // our own handling here so that we can catch exceptions in nested coroutines // instead of just top level coroutine if (topWorker.Current is IEnumerator) { processStack.Push((IEnumerator)topWorker.Current); } else { // Return the current value to the unity engine so it can handle things like // WaitForSeconds, WaitToEndOfFrame, etc. yield return(topWorker.Current); } } }
public IEnumerator Run() { while (true) { var worker = _processStack.Peek(); bool isDone; try { isDone = !worker.MoveNext(); } catch (Exception e) { _awaiter.Complete(default(T), e); yield break; } if (isDone) { _processStack.Pop(); if (_processStack.Count == 0) { _awaiter.Complete((T)worker.Current, null); yield break; } } if (worker.Current is IEnumerator enumerator) { _processStack.Push(enumerator); } else { yield return(worker.Current); } } }
public static IEnumerator ResourceRequest( SimpleCoroutineAwaiter <Object> awaiter, ResourceRequest instruction) { yield return(instruction); awaiter.Complete(instruction.asset, null); }
public static IEnumerator ReturnSelf <T>( SimpleCoroutineAwaiter <T> awaiter, T instruction) { yield return(instruction); awaiter.Complete(instruction, null); }
public static IEnumerator AssetBundleCreateRequest( SimpleCoroutineAwaiter <AssetBundle> awaiter, AssetBundleCreateRequest instruction) { yield return(instruction); awaiter.Complete(instruction.assetBundle, null); }
public static IEnumerator AssetBundleRequest( SimpleCoroutineAwaiter <UnityEngine.Object> awaiter, AssetBundleRequest instruction) { yield return(instruction); awaiter.Complete(instruction.asset, null); }
public static IEnumerator ReturnVoid(SimpleCoroutineAwaiter awaiter, object instruction) { // For simple instructions we assume that they don't throw exceptions yield return(instruction); awaiter.Complete(null); }
public static IEnumerator UnityWebRequest( SimpleCoroutineAwaiter <UnityWebRequest> awaiter, UnityWebRequestAsyncOperation instruction) { yield return(instruction); awaiter.Complete(instruction.webRequest, null); }
public IEnumerator Run() { while (true) { var topWorker = _processStack.Peek(); bool isDone; try { isDone = !topWorker.MoveNext(); } catch (Exception e) { var objectTrace = GenerateObjectTrace(_processStack); if (objectTrace.Any()) { _awaiter.Complete(default(T), new Exception(GenerateObjectTraceMessage(objectTrace), e)); } else { _awaiter.Complete(default(T), e); } yield break; } if (isDone) { _processStack.Pop(); if (_processStack.Count == 0) { _awaiter.Complete((T)topWorker.Current, null); yield break; } } if (topWorker.Current is IEnumerator) { _processStack.Push((IEnumerator)topWorker.Current); } else { yield return(topWorker.Current); } } }
public IEnumerator Run() { while (true) { var topWorker = _processStack.Peek(); bool isDone; try { isDone = !topWorker.MoveNext(); } catch (Exception e) { _awaiter.Complete(null, e); yield break; } if (isDone) { _processStack.Pop(); if (_processStack.Count == 0) { _awaiter.Complete(topWorker.Current, null); yield break; } } // We could just yield return nested IEnumerator's here but we choose to do // our own handling here so that we can catch exceptions in nested coroutines // instead of just top level coroutine if (topWorker.Current is IEnumerator) { _processStack.Push((IEnumerator)topWorker.Current); } else { // Return the current value to the unity engine so it can handle things like // WaitForSeconds, WaitToEndOfFrame, etc. yield return(topWorker.Current); } } }
public static IEnumerator ReturnVoid(SimpleCoroutineAwaiter awaiter, object instruction) { yield return(instruction); awaiter.Complete(null); }