/// <summary> /// Initializes the Easer engine /// </summary> public static void Initialize() { if (_initialized) { return; } EaserDataManager.Init(); _initialized = true; }
/// <summary> /// Similar to Mathf.Lerp, Easer.Ease will return a value between <code>from</code> and <code>to</code>, at <code>t</code> along <code>easeType</code>'s curve. /// </summary> /// <param name="easeType">The EaserEase representing the ease you'd like to use</param> /// <param name="from">float to ease from</param> /// <param name="to">float to ease to</param> /// <param name="t">float between 0 and 1, representing time on curve</param> /// <returns></returns> public static float Ease(EaserEase easeType, float from, float to, float t) { if (!_initialized) { Initialize(); } float value; AnimationCurve curve = EaserDataManager.GetCurve(easeType); if (curve != null) { value = curve.Evaluate(t); } else { value = Mathf.Lerp(0, 1, t); } return(from + ((to - from) * value)); }