UnityEngine.AnimationCurve.EaseInOut C# (CSharp) Method

EaseInOut() public static method

Creates an ease-in and out curve starting at timeStart, valueStart and ending at timeEnd, valueEnd.

public static EaseInOut ( float timeStart, float valueStart, float timeEnd, float valueEnd ) : AnimationCurve
timeStart float The start time for the ease curve.
valueStart float The start value for the ease curve.
timeEnd float The end time for the ease curve.
valueEnd float The end value for the ease curve.
return AnimationCurve
        public static AnimationCurve EaseInOut(float timeStart, float valueStart, float timeEnd, float valueEnd)
        {
            Keyframe[] keys = new Keyframe[] { new Keyframe(timeStart, valueStart, 0f, 0f), new Keyframe(timeEnd, valueEnd, 0f, 0f) };
            return new AnimationCurve(keys);
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Obtains the desired type of animation curve with a duration of 1 (starting on 0), the start value being 0 and the end value being 1
        /// </summary>
        /// <param name="curve">THe desired type of curve.</param>
        /// <returns>The desired type of animation curve with a duration of 1 (starting on 0), the start value being 0 and the end value being 1</returns>
        public static AnimationCurve GetCurve(Curve curve)
        {
            switch (curve)
            {
            case Curve.Linear:
                return(AnimationCurve.Linear(0, 0, 1, 1));

            case Curve.EaseInOut:
                return(AnimationCurve.EaseInOut(0, 0, 1, 1));

            default:
                throw new ArgumentOutOfRangeException(nameof(curve), curve, null);
            }
        }