public static AnimationCurve FixStartEndKeysValues(this AnimationCurve curve, float start = 0f, float end = 1f) { if (!Mathf.Approximately(curve.FirstKey().value, start)) { curve.MoveKey(0, new Keyframe(curve.FirstKey().time, start, curve.FirstKey().inTangent, curve.FirstKey().outTangent)); } if (!Mathf.Approximately(curve.LastKey().value, end)) { curve.MoveKey(curve.keys.Length - 1, new Keyframe(curve.LastKey().time, end, curve.LastKey().inTangent, curve.LastKey().outTangent)); } return(curve); }
public static bool MatchStartEndKeysValues(this AnimationCurve curve, float start = 0f, float end = 1f) { return(Mathf.Approximately(curve.FirstKey().value, start) && Mathf.Approximately(curve.LastKey().value, end)); }