Exemplo n.º 1
0
        public static ITweenPromise Ease(float duration, Func <float, float> easing, MonoBehaviour owner = null)
        {
            var promise = new TweenPromise();

            if (owner == null)
            {
                owner = GetOrCacheTweenRunner();
            }
            owner.StartCoroutine(TweenCoroutine(duration, easing, promise));
            return(promise);
        }
Exemplo n.º 2
0
        private static IEnumerator TweenCoroutine(float duration, Func <float, float> easing, TweenPromise tweenPromise)
        {
            float elapsed = 0;

            do
            {
                yield return(null);

                var progress   = Mathf.Min(1, elapsed / duration);
                var tweenValue = easing(progress);
                tweenPromise.ReportUpdate(tweenValue);
                elapsed += Time.deltaTime;
            } while (tweenPromise.CurState == RSG.PromiseState.Pending && elapsed < duration && !tweenPromise.StopRequested);
            if (tweenPromise.CurState == RSG.PromiseState.Pending)
            {
                tweenPromise.Resolve();
            }
        }