docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Spline

    A wrapper on top of AnimationCurve to handle zero-key curves and keyframe loops.

    Inheritance
    object
    Spline
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Rendering.PostProcessing
    Assembly: Unity.Postprocessing.Runtime.dll
    Syntax
    [Serializable]
    public sealed class Spline

    Constructors

    Spline(AnimationCurve, float, bool, Vector2)

    Creates a new spline.

    Declaration
    public Spline(AnimationCurve curve, float zeroValue, bool loop, Vector2 bounds)
    Parameters
    Type Name Description
    AnimationCurve curve

    The animation curve to base this spline off

    float zeroValue

    The value to return when the curve has no keyframe

    bool loop

    Should this curve loop?

    Vector2 bounds

    The curve bounds

    Fields

    cachedData

    An array holding pre-computed curve values.

    Declaration
    public float[] cachedData
    Field Value
    Type Description
    float[]

    curve

    The underlying animation curve instance.

    Declaration
    public AnimationCurve curve
    Field Value
    Type Description
    AnimationCurve

    k_Precision

    Precision of the curve.

    Declaration
    public const int k_Precision = 128
    Field Value
    Type Description
    int

    k_Step

    The inverse of the precision of the curve.

    Declaration
    public const float k_Step = 0.0078125
    Field Value
    Type Description
    float

    Methods

    Cache(int)

    Caches the curve data at a given frame. The curve data will only be cached once per frame.

    Declaration
    public void Cache(int frame)
    Parameters
    Type Name Description
    int frame

    A frame number

    Evaluate(float)

    Evaluates the curve at a point in time.

    Declaration
    public float Evaluate(float t)
    Parameters
    Type Name Description
    float t

    The time to evaluate

    Returns
    Type Description
    float

    The value of the curve at time t

    Remarks

    Calling the length getter on a curve is expensive to it's better to cache its length and call Evaluate(float, int) instead of getting the length for every call.

    Evaluate(float, int)

    Evaluates the curve at a point in time.

    Declaration
    public float Evaluate(float t, int length)
    Parameters
    Type Name Description
    float t

    The time to evaluate

    int length

    The number of keyframes in the curve

    Returns
    Type Description
    float

    The value of the curve at time t

    GetHashCode()

    Returns the computed hash code for this parameter.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A computed hash code

    Overrides
    object.GetHashCode()
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)