Exemple #1
0
 public static UniTask ToLocalScale(this IAnimatorWithStartValue <Vector2> animator, GameObject gameObject, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(gameObject);
     return(Anime.PlayTo(animator, new LocalScaleTranslator(gameObject.transform), scheduler, CancellationTokenSource.CreateLinkedTokenSource(gameObject.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #2
0
 public static UniTask ToMaterialPropertyInt(this IAnimatorWithStartValue <int> animator, Renderer renderer, string name, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(renderer);
     return(Anime.PlayTo(animator, new MaterialPropertyIntTranslator(renderer, name), scheduler, CancellationTokenSource.CreateLinkedTokenSource(renderer.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
 public static UniTask ToAnchoredPositionY(this IAnimator <float> animator, RectTransform rectTransform, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(rectTransform);
     return(Anime.Play(animator, new AnchoredPositionXTranslator(rectTransform, 1), scheduler, CancellationTokenSource.CreateLinkedTokenSource(rectTransform.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
 public static UniTask ToSizeDelta(this IAnimator <Vector2> animator, GameObject gameObject, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(gameObject);
     return(Anime.Play(animator, new SizeDeltaTranslator(gameObject.GetComponent <RectTransform>()), scheduler, CancellationTokenSource.CreateLinkedTokenSource(gameObject.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #5
0
 public static UniTask Delay(float duration, IScheduler scheduler = default, CancellationToken cancellationToken = default, SkipToken skipToken = default)
 {
     return(DelayInternal(duration, scheduler, cancellationToken, skipToken));
 }
Exemple #6
0
 public static UniTask ToBind <T>(this IAnimator <T> animator, Func <T> getter, Action <T> setter, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     return(Anime.Play(animator, new BindTranslator <T>(getter, setter), scheduler, cancellationToken, skipToken));
 }
Exemple #7
0
 public static UniTask ToColorA(this IAnimatorWithStartValue <float> animator, CanvasGroup canvasGroup, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(canvasGroup);
     return(Anime.PlayTo(animator, new CanvasGroupTranslator(canvasGroup), scheduler, CancellationTokenSource.CreateLinkedTokenSource(canvasGroup.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #8
0
        public static UniTask PlayTo <T>(IAnimatorWithStartValue <T> animatorWithStartValue, IValueTranslator <T> translator, IScheduler scheduler = default, CancellationToken cancellationToken = default, SkipToken skipToken = default)
        {
            var animator = animatorWithStartValue.Start(translator.Current);

            return(PlayInternal(animator, translator, scheduler, cancellationToken, skipToken));
        }
Exemple #9
0
 public static UniTask ToLocalPositionY(this IAnimator <float> animator, GameObject gameObject, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(gameObject);
     return(Anime.Play(animator, new LocalPositionXTranslator(gameObject.transform, 1), scheduler, CancellationTokenSource.CreateLinkedTokenSource(gameObject.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #10
0
 public static UniTask ToProgress <T>(this IAnimator <T> animator, IProgress <T> progress, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     return(Anime.Play(animator, new ProgressTranslator <T>(progress), scheduler, cancellationToken, skipToken));
 }
Exemple #11
0
 public static UniTask ToLocalPositionX(this IAnimatorWithStartValue <float> animator, Component component, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(component);
     return(Anime.PlayTo(animator, new LocalPositionXTranslator(component.transform, 0), scheduler, CancellationTokenSource.CreateLinkedTokenSource(component.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #12
0
 public static UniTask ToGlobalRotation(this IAnimatorWithStartValue <Quaternion> animator, Component component, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(component);
     return(Anime.PlayTo(animator, new GlobalRotationTranslator(component.transform), scheduler, CancellationTokenSource.CreateLinkedTokenSource(component.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #13
0
 public static UniTask ToGlobalRotation(this IAnimator <Quaternion> animator, GameObject gameObject, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(gameObject);
     return(Anime.Play(animator, new GlobalRotationTranslator(gameObject.transform), scheduler, CancellationTokenSource.CreateLinkedTokenSource(gameObject.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #14
0
 public SkipTokenSource()
 {
     IsSkipRequested = false;
     Token           = new SkipToken(this);
 }
Exemple #15
0
 public static UniTask ToText(this IAnimator <float> animator, Text text, string format, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(text);
     return(Anime.Play(animator, new TextTranslator(text, format), scheduler, CancellationTokenSource.CreateLinkedTokenSource(text.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #16
0
 public static UniTask Play <T>(IAnimator <T> animator, ITranslator <T> translator, IScheduler scheduler = default, CancellationToken cancellationToken = default, SkipToken skipToken = default)
 {
     return(PlayInternal(animator, translator, scheduler, cancellationToken, skipToken));
 }
Exemple #17
0
 public static UniTask ToColorA(this IAnimator <float> animator, Graphic graphic, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(graphic);
     return(Anime.Play(animator, new ColorXTranslator(graphic, 3), scheduler, CancellationTokenSource.CreateLinkedTokenSource(graphic.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #18
0
        private static async UniTask PlayInternal <T>(IAnimator <T> animator, ITranslator <T> translator, IScheduler scheduler, CancellationToken cancellationToken, SkipToken skipToken)
        {
            if (scheduler == default)
            {
                scheduler = DefaultScheduler;
            }

            var startTime = scheduler.Now;
            var playState = Application.isPlaying;

            while (!cancellationToken.IsCancellationRequested && !skipToken.IsSkipRequested && playState == Application.isPlaying)
            {
                var time = scheduler.Now - startTime;
                var(t, used) = animator.Update(time);
                translator.Update(t);
                if (used < time)
                {
                    break;
                }
                await UniTask.Yield(PlayerLoopTiming.Update, cancellationToken);
            }

            cancellationToken.ThrowIfCancellationRequested();

            if (skipToken.IsSkipRequested)
            {
                var(t, _) = animator.Update(float.MaxValue);
                translator.Update(t);
            }
        }
Exemple #19
0
 public static UniTask ToFillAmount(this IAnimatorWithStartValue <float> animator, Image image, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(image);
     return(Anime.PlayTo(animator, new FillAmountTranslator(image), scheduler, CancellationTokenSource.CreateLinkedTokenSource(image.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #20
0
        private static async UniTask DelayInternal(float duration, IScheduler scheduler, CancellationToken cancellationToken, SkipToken skipToken)
        {
            if (scheduler == default)
            {
                scheduler = DefaultScheduler;
            }

            var startTime = scheduler.Now;
            var playState = Application.isPlaying;

            while (!cancellationToken.IsCancellationRequested && !skipToken.IsSkipRequested && playState == Application.isPlaying)
            {
                var time = scheduler.Now - startTime;
                if (duration < time)
                {
                    break;
                }
                await UniTask.Yield(PlayerLoopTiming.Update, cancellationToken);
            }
            cancellationToken.ThrowIfCancellationRequested();
        }
Exemple #21
0
        private static async UniTask PlayInternal <T>(IAnimator <T> animator, ITranslator <T> translator, IScheduler scheduler, CancellationToken cancellationToken, SkipToken skipToken)
        {
            if (scheduler == default)
            {
                scheduler = DefaultScheduler;
            }

            var time      = 0f;
            var playState = Application.isPlaying;

            while (!cancellationToken.IsCancellationRequested && !skipToken.IsSkipRequested && translator.Alive && playState == Application.isPlaying)
            {
                var(t, used) = animator.Update(time);
                translator.Update(t);
                if (used < time)
                {
                    break;
                }
                await UniTask.NextFrame(scheduler.UpdateTiming, cancellationToken);

                time += scheduler.DeltaTime;
            }

            if (!translator.Alive)
            {
                throw new OperationCanceledException("!translator.Alive");
            }
            cancellationToken.ThrowIfCancellationRequested();

            if (skipToken.IsSkipRequested)
            {
                var(t, _) = animator.Update(float.MaxValue);
                translator.Update(t);
            }
        }
Exemple #22
0
 public static UniTask ToBind <T>(this IAnimatorWithStartValue <T> animator, Func <T> getter, Action <T> setter, Object unityObject, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     return(Anime.PlayTo(animator, new BindTranslatorWithObject <T>(getter, setter, unityObject), scheduler, cancellationToken, skipToken));
 }
Exemple #23
0
        private static async UniTask DelayInternal(float duration, IScheduler scheduler, CancellationToken cancellationToken, SkipToken skipToken)
        {
            if (scheduler == default)
            {
                scheduler = DefaultScheduler;
            }

            var time      = 0f;
            var playState = Application.isPlaying;

            while (!cancellationToken.IsCancellationRequested && !skipToken.IsSkipRequested && playState == Application.isPlaying)
            {
                if (duration < time)
                {
                    break;
                }
                await UniTask.NextFrame(scheduler.UpdateTiming, cancellationToken);

                time += scheduler.DeltaTime;
            }
            cancellationToken.ThrowIfCancellationRequested();
        }
 public static UniTask ToAnchoredPositionY(this IAnimatorWithStartValue <float> animator, Graphic graphic, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(graphic);
     return(Anime.PlayTo(animator, new AnchoredPositionXTranslator(graphic.rectTransform, 1), scheduler, CancellationTokenSource.CreateLinkedTokenSource(graphic.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #25
0
 public static UniTask ToMaterialPropertyFloat(this IAnimator <float> animator, Renderer renderer, int nameID, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(renderer);
     return(Anime.Play(animator, new MaterialPropertyFloatTranslator(renderer, nameID), scheduler, CancellationTokenSource.CreateLinkedTokenSource(renderer.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
 public static UniTask ToSizeDelta(this IAnimator <Vector2> animator, Graphic graphic, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(graphic);
     return(Anime.Play(animator, new SizeDeltaTranslator(graphic.rectTransform), scheduler, CancellationTokenSource.CreateLinkedTokenSource(graphic.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }
Exemple #27
0
 public static UniTask ToLocalScale(this IAnimator <Vector2> animator, Component component, CancellationToken cancellationToken = default, SkipToken skipToken = default, IScheduler scheduler = default)
 {
     CheckAlive(component);
     return(Anime.Play(animator, new LocalScaleTranslator(component.transform), scheduler, CancellationTokenSource.CreateLinkedTokenSource(component.GetCancellationTokenOnDestroy(), cancellationToken).Token, skipToken));
 }