Last active
August 6, 2021 00:11
-
-
Save Sztorm/9bd608029802de1892f68d69bf4dd7cd to your computer and use it in GitHub Desktop.
AnimationCurveUtils containing EaseIn and EaseOut functions. Public domain.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public static class AnimationCurveUtils | |
{ | |
/// <summary> | |
/// Creates an ease-in curve starting at timeStart, valueStart and ending at timeEnd, | |
/// valueEnd. | |
/// </summary> | |
/// <param name="timeStart">The start time for the ease-in curve.</param> | |
/// <param name="valueStart">The start value for the ease-in curve.</param> | |
/// <param name="timeEnd">The end time for the ease-in curve.</param> | |
/// <param name="valueEnd">The end value for the ease-in curve.</param> | |
/// <returns>The ease-in curve generated from the specified values.</returns> | |
public static AnimationCurve EaseIn( | |
float timeStart, float valueStart, float timeEnd, float valueEnd) | |
=> new AnimationCurve( | |
new Keyframe(timeStart, valueStart, inTangent: 0F, outTangent: 0F), | |
new Keyframe(timeEnd, valueEnd, inTangent: 2F, outTangent: 2F)); | |
/// <summary> | |
/// Creates an ease-out curve starting at timeStart, valueStart and ending at timeEnd, | |
/// valueEnd. | |
/// </summary> | |
/// <param name="timeStart">The start time for the ease-out curve.</param> | |
/// <param name="valueStart">The start value for the ease-out curve.</param> | |
/// <param name="timeEnd">The end time for the ease-out curve.</param> | |
/// <param name="valueEnd">The end value for the ease-out curve.</param> | |
/// <returns>The ease-out curve generated from the specified values.</returns> | |
public static AnimationCurve EaseOut( | |
float timeStart, float valueStart, float timeEnd, float valueEnd) | |
=> new AnimationCurve( | |
new Keyframe(timeStart, valueStart, inTangent: 2F, outTangent: 2F), | |
new Keyframe(timeEnd, valueEnd, inTangent: 0F, outTangent: 0F)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment