예제 #1
0
        private IEnumerator ExecuteCoroutineAction(CoroutineAction action, bool outOfFlow = false)
        {
            IEnumerator enumerator = action.action();

            while (true)
            {
                object current;
                try
                {
                    if (enumerator.MoveNext() == false)
                    {
                        action.OnSuccessCallback?.Invoke();
                        break;
                    }
                    current = enumerator.Current;
                }
                catch (Exception e)
                {
                    action.OnFailureCallback?.Invoke(e);

                    if (action.WillStopOnError)
                    {
                        StopAll();
                    }

                    yield break;
                }
                yield return(current);
            }
        }
예제 #2
0
 public static GameAction TestCoroutine(int duration) =>
 CoroutineAction
 .Create("Test Coroutine", () => TestCoroutineMethod(duration));
예제 #3
0
 public static GameAction TestCoroutineWithError(int duration, Exception error) =>
 CoroutineAction
 .Create("Test Coroutine With Error", () => TestCoroutineMethod(duration, error));
예제 #4
0
 public static GameAction Wait(float duration) => CoroutineAction.Create(string.Format("Waiting for {0}sec", duration), () => RunWait(duration));