//====================================================================== HELPERS private void Tween(T startValue, T endValue, HiraTweenEaseType easeType, Action callback) { Stop(); CurrentTracker = new HiraTween(duration, f => Target.Invoke(InterpolationFunction(startValue, endValue, f)), type, easeType, callback).Start(); }
// Generic Constructor public HiraTween(float time, Action <float> onIteration, HiraTweenterpolationType tweenType = HiraTweenterpolationType.Linear, HiraTweenEaseType easeType = HiraTweenEaseType.EaseIn, Action onCompletion = null) { Time = time; OnIteration = onIteration; TweenType = tweenType; EaseType = easeType; OnCompletion = onCompletion; }
internal static Func <float, float> GetInterpolationMethod(HiraTweenEaseType easeType) { // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault switch (easeType) { case HiraTweenEaseType.EaseIn: return(EaseIn); case HiraTweenEaseType.EaseOut: return(EaseOut); case HiraTweenEaseType.EaseInOut: return(EaseInOut); default: throw new ArgumentOutOfRangeException(nameof(easeType), easeType, null); } }
// Vector2 Tween Constructor public HiraTween(Action <Vector2> setter, Vector2 a, Vector2 b, float time, HiraTweenterpolationType tweenType = HiraTweenterpolationType.Linear, HiraTweenEaseType easeType = HiraTweenEaseType.EaseIn, Action onCompletion = null) { Time = time; OnIteration = t => setter(Vector2.LerpUnclamped(a, b, t)); OnCompletion = onCompletion; TweenType = tweenType; EaseType = easeType; }
// Quaternion Tween Constructor public HiraTween(Action <Quaternion> setter, Quaternion a, Quaternion b, float time, HiraTweenterpolationType tweenType = HiraTweenterpolationType.Linear, HiraTweenEaseType easeType = HiraTweenEaseType.EaseIn, Action onCompletion = null) { Time = time; OnIteration = t => setter(Quaternion.SlerpUnclamped(a, b, t)); OnCompletion = onCompletion; TweenType = tweenType; EaseType = easeType; }
// Euler Tween Constructor public HiraTween(Action <Vector3> setter, Quaternion a, Quaternion b, float time, HiraTweenterpolationType tweenType = HiraTweenterpolationType.Linear, HiraTweenEaseType easeType = HiraTweenEaseType.EaseIn, Action onCompletion = null) { Time = time; var(x, y) = (a.eulerAngles, b.eulerAngles); OnIteration = t => setter(Vector3.SlerpUnclamped(x, y, t)); OnCompletion = onCompletion; TweenType = tweenType; EaseType = easeType; }
internal static Func <float, float> GetInterpolationMethod(HiraTweenEaseType easeType) { switch (easeType) { case HiraTweenEaseType.EaseIn: return(EaseIn); case HiraTweenEaseType.EaseOut: return(EaseOut); case HiraTweenEaseType.EaseInOut: return(EaseInOut); default: throw new ArgumentOutOfRangeException(nameof(easeType), easeType, null); } }
internal static Func <float, float> GetInterpolationMethod(HiraTweenEaseType easeType) => Interpolate;