AnimationCurveUtility
AnimationCurveUtility is a static utility class that allows easy creation of various AnimationCurves. The full API docs can be found here.
Predefined curves
All of the easing functions presented at this link are implemented: https://easings.net/
You can create the corresponding AnimationCurve like this: AnimationCurveUtility.EaseInOutSine().
You can also get the Bézier points (don't worry about what this means if you don't know 😄) that define the AnimationCurve, so you can manipulate them to easily
create slightly modified versions of the existing curves using the Bézier constructors.
Bezier constructors
You can create AnimationCurves using Bézier points.
Simply call Bezier(params Vector2[] points) with your points Bézier points.
The method will automatically infer whether you are creating a linear, quadratic or cubic Bézier curve based on the amount of points.
If the amount of points does not clearly indicate one specific type, higher degree Bézier curves are preferred.
There are also the LinearBezier, QuadraticBezier, and CubicBezier methods, if you want to make sure the correct degree Bézier curve is created.
⚠️ When creating your own AnimationCurves like this, always keep in the back of your mind that Unity's AnimationCurves use time as input; this means the Bézier curve must at all times advance on the X axis, or you will get an invalid AnimationCurve.
For example, imagine the quadratic curve defined by the points (0,0), (0,1), (1,1):
This will yield an invalid curve! Consider the very beginning of this curve. At the very beginning, the curve moves perfectly straight up; that is not possible in AnimationCurves.
Something even more extreme, like the curve moving "back" / to the left, is of course not possible either:
Huge props to qwe321qwe321qwe321 on GitHub for his BezierToAnimationCurve implementation, as well as the optimized curve points!