Esempio n. 1
0
        public void Tween(TProperty value, UIAnimationDirection animationDirection = UIAnimationDirection.From,
                          Action callback = null, UIAnimationOptions animationOptions = null)
        {
            if (animationOptions == null)
            {
                animationOptions = new UIAnimationOptions();
            }

            if (tweenerCoroutine != null && tweenerCoroutine.Running)
            {
                StopTween();
                tweenerCoroutine.OnFinished += b => {
                    Tween(value, animationDirection, callback, animationOptions);
                };
                return;
            }

            if (animationDirection == UIAnimationDirection.RelativeTo || animationDirection == UIAnimationDirection.RelativeFrom)
            {
                value = AddValues(value, TargetValue);
            }

            if (animationDirection == UIAnimationDirection.To || animationDirection == UIAnimationDirection.RelativeTo)
            {
                TargetValue = value;
            }
            else
            {
                TargetValue  = CurrentValue;
                CurrentValue = value;
            }

            if (animationOptions.SavePosition)
            {
                SavedValue = TargetValue;
            }

            if (animationOptions.Instant)
            {
                CurrentValue = TargetValue;
                return;
            }

            Tweening = true;

            tweenerCoroutine             = _owner.CreateCoroutine(TweenCoroutine(animationOptions.Ease, animationOptions.Duration, animationOptions.Delay));
            tweenerCoroutine.OnFinished += stopped => {
                if (!stopped)
                {
                    CurrentValue = TargetValue;
                }

                Tweening = false;

                callback?.Invoke();
            };
        }
Esempio n. 2
0
 public static ECoroutine CreateUpdateCoroutine(this MonoBehaviour monoBehaviour, Action action, float delay,
                                                bool autoStart = true)
 {
     return(monoBehaviour.CreateCoroutine(action.ToUpdateIEnumerator(delay), autoStart));
 }
Esempio n. 3
0
 public static ECoroutine CreateActionCoroutine(this MonoBehaviour monoBehaviour, Action action,
                                                bool autoStart = true)
 {
     return(monoBehaviour.CreateCoroutine(action.ToIEnumerator(), autoStart));
 }