Beispiel #1
0
 private void RunInternal(CoroutineCallbackWrapper wrapper)
 {
     if (numActive < maxActive)
     {
         IEnumerator runner = CoroutineRunner(wrapper);
         coroutineStarter(runner);
     }
     else
     {
         queue.Enqueue(wrapper);
     }
 }
Beispiel #2
0
        private IEnumerator CoroutineRunner(CoroutineCallbackWrapper wrapper)
        {
            numActive++;
            IEnumerator coroutine = wrapper.Coroutine;

            while (true)
            {
                object current;
                try
                {
                    if (coroutine.MoveNext() == false)
                    {
                        break;
                    }
                    current = coroutine.Current;
                }
                catch (System.Exception ex)
                {
                    if (OnCoroutineError != null)
                    {
                        OnCoroutineError(ex.Message);
                    }
                    wrapper.ExecCallback(false);
                    numActive--;
                    yield break;
                }
                yield return(current);
            }
            wrapper.ExecCallback(true);
            numActive--;
            if (queue.Count > 0)
            {
                CoroutineCallbackWrapper next = queue.Dequeue();
                RunInternal(next);
            }
        }
Beispiel #3
0
        public void Run(IEnumerator coroutine, Action <bool> callback = null)
        {
            CoroutineCallbackWrapper wrapper = new CoroutineCallbackWrapper(coroutine, callback);

            RunInternal(wrapper);
        }