public static float GetNormalizedValue(this AnimationCurve curve, float t) { float tmin = curve.GetMinTime(); float tmax = curve.GetMaxTime(); float lerp = Mathf.Lerp(tmin, tmax, t); float v = curve.Evaluate(lerp); tmin = curve.GetStartValue(); tmax = curve.GetEndValue(); float len = tmax - tmin; return(len == 0 ? v : (v - tmin) / len); }
public static float ClampTime(this AnimationCurve curve, float time) { return(Mathf.Clamp(time, curve.GetMinTime(), curve.GetMaxTime())); }