Class Spline
A wrapper on top of AnimationCurve to handle zero-key curves and keyframe loops.
Inherited Members
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 |
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 |
GetHashCode()
Returns the computed hash code for this parameter.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A computed hash code |