public LerpCoroutine(float duration, ILerp <T> lerper, Easing.Functions function, Action <T> action) : base() { this.duration = duration > 0F ? duration : Mathf.Epsilon; this.action = (t) => { InterpolatedValue = lerper.Lerp(t, Easing.Get(function)); action(InterpolatedValue); }; }
public void Init(Easing.Functions easing) { this.easing = easing; for (float t = 0f; t < 1f; t += 0.01f) { RectTransform newDot = Instantiate(lineDot, CalculatePosition(t, easing), Quaternion.identity, lineDot.transform.parent); } Destroy(lineDot.gameObject); }
public static GenericTweenResolution <T> Create(float time, T from, T to, Action <T, T, float> onUpdate, Easing.Functions easing, bool unscaled, Promise promise) { var r = ObjectPool.Pop <GenericTweenResolution <T> >(); r._time = time; r._from = from; r._to = to; r._onUpdate = onUpdate; r._easing = easing; r._unscaled = unscaled; r._promise = promise; return(r); }
private static IEnumerator TweenRoutine <T>(float time, T from, T to, Easing.Functions easing, Action <T, T, float> onUpdate, bool unscaled = false) { var f = 0f; while (f <= time) { onUpdate(from, to, Easing.Interpolate(f / time, easing)); var deltaTime = unscaled ? Time.unscaledDeltaTime : Time.deltaTime; f += deltaTime; yield return(null); } onUpdate(from, to, 1f); }
public IPromise ThenTween(float time, Action <float> onUpdate, Easing.Functions easing = Easing.Functions.Linear, bool unscaled = false) { var p = Create(); if (CurrentState == EPromiseState.Resolved) { CoroutineExtensions.Tween(time, onUpdate, easing, unscaled).ThenResolvePromise(p, PromisedObject); } else { _resolutions.Add(TweenResolution.Create(time, onUpdate, easing, unscaled, p)); } return(p); }
/// <summary> /// Interpolates between min and max by t. /// </summary> /// <param name="t"> /// The interpolation value between 0f and 1f. /// </param> /// <param name="function"> /// The Easing function. /// </param> public T Lerp(float t, Easing.Functions function) { return(Lerp(t, Easing.Get(function))); }
public static Func <float, bool> Translate(Easing.Functions function, float duration, Transform transform, float distance) { return(Translate(Easing.Get(function), duration, transform, distance)); }
public static Func <float, Vector3> GetVector3(Easing.Functions function, float duration, Vector3 start, Vector3 end, float angle = 0F) { return(GetVector3(Easing.Get(function), duration, start, end, angle)); }
public static Func <float, Vector2> GetVector2(Easing.Functions function, float duration, Vector2 start, Vector2 end) { return(GetVector2(Easing.Get(function), duration, start, end)); }
public static Func <float, float> Ease(Easing.Functions function) { return(Easing.Get(function)); }
public static TweenResolution Create(float time, Action <float> onUpdate, Easing.Functions easing, bool unscaled, Promise promise) { var r = ObjectPool.Pop <TweenResolution>(); r._time = time; r._onUpdate = onUpdate; r._easing = easing; r._unscaled = unscaled; r._promise = promise; return(r); }
public static IPromise Tween <T>(float time, T from, T to, Action <T, T, float> onUpdate, Easing.Functions easing = Easing.Functions.Linear, bool unscaled = false) { return(WaitForCoroutine(TweenRoutine <T>(time, from, to, easing, onUpdate, unscaled))); }
public static IPromise Tween(float time, Action <float> onUpdate, Easing.Functions easing = Easing.Functions.Linear, bool unscaled = false) { return(WaitForCoroutine(TweenRoutine <float>(time, 0f, 0f, easing, ((from, to, t) => onUpdate(t)), unscaled))); }
private Vector2 CalculatePosition(float time, Easing.Functions easing) { Rect rect = (transform as RectTransform).rect; return((Vector2)transform.position + new Vector2(Mathf.LerpUnclamped(rect.xMin, rect.xMax, time), Mathf.LerpUnclamped(rect.yMin, rect.yMax, Easing.Interpolate(time, easing)))); }