StartCoroutine() 공개 정적인 메소드

public static StartCoroutine ( IEnumerator routine ) : Coroutine
routine IEnumerator
리턴 UnityEngine.Coroutine
예제 #1
0
        public static CoroutineAsyncBridge Start <T>(T awaitTarget)
        {
            var bridge = new CoroutineAsyncBridge();

            MainThreadDispatcher.StartCoroutine(bridge.Run(awaitTarget));
            return(bridge);
        }
예제 #2
0
        public static IObservable <T> DelayFrame <T>(this IObservable <T> source, int frameCount)
        {
            if (frameCount < 0)
            {
                throw new ArgumentOutOfRangeException("frameCount");
            }

            return(Observable.Create <T>(observer =>
            {
                var cancel = new BooleanDisposable();

                source.Materialize().Subscribe(x =>
                {
                    if (x.Kind == NotificationKind.OnError)
                    {
                        observer.OnError(x.Exception);
                        cancel.Dispose();
                        return;
                    }

                    MainThreadDispatcher.StartCoroutine(DelayFrameCore(() => x.Accept(observer), frameCount, cancel));
                });

                return cancel;
            }));
        }
        public static Coroutine StartCoroutine(IEnumerator routine)
        {
            MainThreadDispatcher mainThreadDispatcher = MainThreadDispatcher.Instance;

            if (mainThreadDispatcher != null)
            {
                return(mainThreadDispatcher.StartCoroutine(routine));
            }
            return(null);
        }
예제 #4
0
        public static IObservable <T> FromCoroutine <T>(Func <IObserver <T>, CancellationToken, IEnumerator> coroutine)
        {
            return(Observable.Create <T>(observer =>
            {
                var cancel = new BooleanDisposable();

                MainThreadDispatcher.StartCoroutine(coroutine(observer, new CancellationToken(cancel)));

                return cancel;
            }));
        }
            public IDisposable Schedule <TState>(TState state, TimeSpan dueTime, Func <IScheduler, TState, IDisposable> action)
            {
                var d = new SingleAssignmentDisposable();

                MainThreadDispatcher.StartCoroutine(DelayAction(dueTime, () =>
                {
                    if (!d.IsDisposed)
                    {
                        d.Disposable = action(this, state);
                    }
                }));

                return(d);
            }
 private void Awake()
 {
     if (MainThreadDispatcher.instance == null)
     {
         MainThreadDispatcher.instance        = this;
         MainThreadDispatcher.mainThreadToken = new object();
         MainThreadDispatcher.initialized     = true;
         this.updateMicroCoroutine            = new MicroCoroutine(delegate(Exception ex)
         {
             this.unhandledExceptionCallback(ex);
         });
         this.fixedUpdateMicroCoroutine = new MicroCoroutine(delegate(Exception ex)
         {
             this.unhandledExceptionCallback(ex);
         });
         this.endOfFrameMicroCoroutine = new MicroCoroutine(delegate(Exception ex)
         {
             this.unhandledExceptionCallback(ex);
         });
         MainThreadDispatcher.StartCoroutine(this.RunUpdateMicroCoroutine());
         MainThreadDispatcher.StartCoroutine(this.RunFixedUpdateMicroCoroutine());
         MainThreadDispatcher.StartCoroutine(this.RunEndOfFrameMicroCoroutine());
         UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
     }
     else if (this != MainThreadDispatcher.instance)
     {
         if (MainThreadDispatcher.cullingMode == MainThreadDispatcher.CullingMode.Self)
         {
             global::Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Removing myself...");
             MainThreadDispatcher.DestroyDispatcher(this);
         }
         else if (MainThreadDispatcher.cullingMode == MainThreadDispatcher.CullingMode.All)
         {
             global::Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Cleaning up all excess dispatchers...");
             MainThreadDispatcher.CullAllExcessDispatchers();
         }
         else
         {
             global::Debug.LogWarning("There is already a MainThreadDispatcher in the scene.");
         }
     }
 }
 public static void SendStartCoroutine(IEnumerator routine)
 {
     if (MainThreadDispatcher.mainThreadToken != null)
     {
         MainThreadDispatcher.StartCoroutine(routine);
     }
     else
     {
         MainThreadDispatcher mainThreadDispatcher = MainThreadDispatcher.Instance;
         if (mainThreadDispatcher != null)
         {
             mainThreadDispatcher.queueWorker.Enqueue(delegate
             {
                 MainThreadDispatcher mainThreadDispatcher2 = MainThreadDispatcher.Instance;
                 if (mainThreadDispatcher2 != null)
                 {
                     mainThreadDispatcher2.StartCoroutine_Auto(routine);
                 }
             });
         }
     }
 }
 public static void SendStartCoroutine(IEnumerator routine)
 {
     if (MainThreadDispatcher.mainThreadToken != null)
     {
         MainThreadDispatcher.StartCoroutine(routine);
     }
     else
     {
         MainThreadDispatcher mainThreadDispatcher = MainThreadDispatcher.Instance;
         if (!MainThreadDispatcher.isQuitting && !object.ReferenceEquals(mainThreadDispatcher, null))
         {
             mainThreadDispatcher.queueWorker.Enqueue(delegate(object _)
             {
                 MainThreadDispatcher mainThreadDispatcher2 = MainThreadDispatcher.Instance;
                 if (mainThreadDispatcher2 != null)
                 {
                     mainThreadDispatcher2.StartCoroutine(routine);
                 }
             }, null);
         }
     }
 }
예제 #9
0
 /// <summary>AutoStart observable as coroutine.</summary>
 public static Coroutine StartAsCoroutine <T>(this IObservable <T> source, Action <T> onResult, Action <Exception> onError, CancellationToken cancel = default(CancellationToken))
 {
     return(MainThreadDispatcher.StartCoroutine(source.ToAwaitableEnumerator(onResult, onError, cancel)));
 }
예제 #10
0
        public static Coroutine WhenAll(IEnumerable <LazyTask> tasks)
        {
            var coroutines = tasks.Select(x => x.Start()).ToArray();

            return(MainThreadDispatcher.StartCoroutine(WhenAllCore(coroutines)));
        }
예제 #11
0
 public static Coroutine WhenAll(IEnumerable <LazyTask> tasks)
 {
     Coroutine[] coroutines = Enumerable.ToArray <Coroutine>(Enumerable.Select <LazyTask, Coroutine>(tasks, (LazyTask x) => x.Start()));
     return(MainThreadDispatcher.StartCoroutine(LazyTask.WhenAllCore(coroutines)));
 }
예제 #12
0
 public static Coroutine WhenAll(IEnumerable <LazyTask> tasks)
 {
     Coroutine[] coroutines = (from x in tasks
                               select x.Start()).ToArray();
     return(MainThreadDispatcher.StartCoroutine(WhenAllCore(coroutines)));
 }