public static void SetEaseByClip(this Tween tween, IAnimationEase animationEase) { switch (animationEase.EaseType) { case UEaseType.Ease: tween.SetEase(animationEase.Ease); break; case UEaseType.Curve: tween.SetEase(animationEase.Curve); break; } }
public static AnimationBehaviour CreateAnimation(this MonoBehaviour monoBehaviour, IAnimationEase ease, float duration, float delay = 0f, string name = null, StartCallback startCallback = null, UpdateCallback updateCallback = null, CancelCallback cancelCallback = null, DoneCallback doneCallback = null, FinishCallback finishCallback = null, bool single = false, bool considerTimeScale = false, object data = null, bool inverse = false) { if (single) { if (string.IsNullOrEmpty(name)) { Debug.Log("Animation can just be single if its name is not empty neither null."); } else { CancelAnimations(monoBehaviour, name); } } var gameObject = monoBehaviour.gameObject; var anim = gameObject.AddComponent <AnimationBehaviour>(); anim.Delay = delay; anim.Name = name; anim.Ease = ease; anim.StartCallback = startCallback; anim.UpdateCallback = updateCallback; anim.FinishCallback = finishCallback; anim.Duration = duration; anim.DoneCallback = doneCallback; anim.CancelCallback = cancelCallback; anim.ConsiderTimeScale = considerTimeScale; anim.Data = data ?? monoBehaviour; anim.Inverse = inverse; anim.Start(); return(anim); }