示例#1
0
            public static IEnumerator ResourceRequest(
                UnityAwaiter <UnityEngine.Object> awaiter, ResourceRequest instruction)
            {
                yield return(instruction);

                awaiter.Complete(instruction.asset, null);
            }
示例#2
0
            public static IEnumerator ReturnSelf <T>(
                UnityAwaiter <T> awaiter, T instruction)
            {
                yield return(instruction);

                awaiter.Complete(instruction, null);
            }
示例#3
0
        protected virtual void Awake()
        {
            updateQueues = new List <ContinuationQueue>
            {
                new ContinuationQueue <FrameContinuation>(128),
                new ContinuationQueue <TimeContinuation>(64),
                new ContinuationQueue <UnscaledTimeContinuation>(32),
                new ContinuationQueue <ConditionContinuation>(32),
                new ContinuationQueue <CustomContinuation>(16),
                new ContinuationQueue <AsyncOpContinuation>(16)
            };

            lateUpdateQueues = new List <ContinuationQueue> {
                new ContinuationQueue <FrameContinuation>(32)
            };
            fixedUpdateQueues = new List <ContinuationQueue> {
                new ContinuationQueue <FixedContinuation>(32)
            };

            updateAwaiter      = new UnityAwaiter <FrameContinuation>(updateQueues[0]);
            lateUpdateAwaiter  = new UnityAwaiter <FrameContinuation>(lateUpdateQueues[0]);
            fixedUpdateAwaiter = new UnityAwaiter <FixedContinuation>(fixedUpdateQueues[0]);

            timeAwaiter         = new UnityAwaiter <TimeContinuation>(updateQueues[1]);
            unscaledTimeAwaiter = new UnityAwaiter <UnscaledTimeContinuation>(updateQueues[2]);

            conditionAwaiter = new UnityAwaiter <ConditionContinuation>(updateQueues[3]);
            customAwaiter    = new UnityAwaiter <CustomContinuation>(updateQueues[4]);
            asyncOpAwaiter   = new UnityAwaiter <AsyncOpContinuation>(updateQueues[5]);
        }
示例#4
0
            public static IEnumerator AssetBundleCreateRequest(
                UnityAwaiter <AssetBundle> awaiter, AssetBundleCreateRequest instruction)
            {
                yield return(instruction);

                awaiter.Complete(instruction.assetBundle, null);
            }
示例#5
0
 public CoroutineWrapper(
     IEnumerator coroutine, UnityAwaiter <T> awaiter)
 {
     _processStack = new Stack <IEnumerator>();
     _processStack.Push(coroutine);
     _awaiter = awaiter;
 }
示例#6
0
            public static IEnumerator ReturnVoid(
                UnityAwaiter awaiter, object instruction)
            {
                // 暂且认定不会抛异常
                yield return(instruction);

                awaiter.Complete(null);
            }
示例#7
0
        static UnityAwaiter <T> GetAwaiterReturnSelf <T>(T instruction)
        {
            var awaiter = new UnityAwaiter <T>();

            RunOnUnityScheduler(() => AsyncCoroutineRunner.Instance.StartCoroutine(
                                    InstructionWrappers.ReturnSelf(awaiter, instruction)));
            return(awaiter);
        }
示例#8
0
        public static UnityAwaiter <object> GetAwaiter(this IEnumerator coroutine)
        {
            var awaiter = new UnityAwaiter <object>();

            RunOnUnityScheduler(() => AsyncCoroutineRunner.Instance.StartCoroutine(
                                    new CoroutineWrapper <object>(coroutine, awaiter).Run()));
            return(awaiter);
        }
示例#9
0
        public static UnityAwaiter <UnityEngine.Object> GetAwaiter(this AssetBundleRequest instruction)
        {
            var awaiter = new UnityAwaiter <UnityEngine.Object>();

            RunOnUnityScheduler(() => AsyncCoroutineRunner.Instance.StartCoroutine(
                                    InstructionWrappers.AssetBundleRequest(awaiter, instruction)));
            return(awaiter);
        }
示例#10
0
        public static UnityAwaiter <T> GetAwaiter <T>(this WaitForFunc <T> waitForFunc)
        {
            var awaiter = new UnityAwaiter <T>();

            if (waitForFunc.GetFunc() != null)
            {
                RunOnUnityScheduler(() => AsyncCoroutineRunner.Instance.StartCoroutine(InstructionWrappers.FuncGetReturn <T>(awaiter, waitForFunc.GetFunc())));
            }
            return(awaiter);
        }
示例#11
0
        public static UnityAwaiter GetAwaiter <T>(this WaitForAction <T> waitForAction)
        {
            var awaiter = new UnityAwaiter();

            if (waitForAction.GetAction() != null)
            {
                RunOnUnityScheduler(waitForAction.GetAction(), waitForAction.GetData());
            }
            awaiter.Complete(null);
            return(awaiter);
        }
示例#12
0
            public static IEnumerator FuncGetReturn <T>(UnityAwaiter <T> awaiter, Func <T> func)
            {
                yield return(null);

                awaiter.Complete(func(), null);
            }