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(); }; }
public static ECoroutine CreateUpdateCoroutine(this MonoBehaviour monoBehaviour, Action action, float delay, bool autoStart = true) { return(monoBehaviour.CreateCoroutine(action.ToUpdateIEnumerator(delay), autoStart)); }
public static ECoroutine CreateActionCoroutine(this MonoBehaviour monoBehaviour, Action action, bool autoStart = true) { return(monoBehaviour.CreateCoroutine(action.ToIEnumerator(), autoStart)); }