Class TextureCurve
A wrapper around AnimationCurve
to automatically bake it into a texture.
Implements
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
[Serializable]
public class TextureCurve : IDisposable
Constructors
TextureCurve(AnimationCurve, float, bool, in Vector2)
Creates a new TextureCurve from an existing AnimationCurve
.
Declaration
public TextureCurve(AnimationCurve baseCurve, float zeroValue, bool loop, in Vector2 bounds)
Parameters
Type | Name | Description |
---|---|---|
AnimationCurve | baseCurve | The source |
float | zeroValue | The default value to use when the curve doesn't have any key. |
bool | loop | Should the curve automatically loop in the given |
Vector2 | bounds | The boundaries of the curve. |
TextureCurve(Keyframe[], float, bool, in Vector2)
Creates a new TextureCurve from an arbitrary number of keyframes.
Declaration
public TextureCurve(Keyframe[] keys, float zeroValue, bool loop, in Vector2 bounds)
Parameters
Type | Name | Description |
---|---|---|
Keyframe[] | keys | An array of Keyframes used to define the curve. |
float | zeroValue | The default value to use when the curve doesn't have any key. |
bool | loop | Should the curve automatically loop in the given |
Vector2 | bounds | The boundaries of the curve. |
Properties
this[int]
Retrieves the key at index.
Declaration
public Keyframe this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The index to look for. |
Property Value
Type | Description |
---|---|
Keyframe | A key. |
length
The number of keys in the curve.
Declaration
public int length { get; }
Property Value
Type | Description |
---|---|
int |
Methods
AddKey(float, float)
Adds a new key to the curve.
Declaration
public int AddKey(float time, float value)
Parameters
Type | Name | Description |
---|---|---|
float | time | The time at which to add the key. |
float | value | The value for the key. |
Returns
Type | Description |
---|---|
int | The index of the added key, or -1 if the key could not be added. |
Dispose()
Cleans up the internal texture resource.
Declaration
[Obsolete("Please use Release() instead.")]
public void Dispose()
Evaluate(float)
Evaluate a time value on the curve.
Declaration
public float Evaluate(float time)
Parameters
Type | Name | Description |
---|---|---|
float | time | The time within the curve you want to evaluate. |
Returns
Type | Description |
---|---|
float | The value of the curve, at the point in time specified. |
~TextureCurve()
Finalizer.
Declaration
protected ~TextureCurve()
GetTexture()
Gets the texture representation of this curve.
Declaration
public Texture2D GetTexture()
Returns
Type | Description |
---|---|
Texture2D | A 128x1 texture. |
MoveKey(int, in Keyframe)
Removes the keyframe at index
and inserts key
.
Declaration
public int MoveKey(int index, in Keyframe key)
Parameters
Type | Name | Description |
---|---|---|
int | index | |
Keyframe | key |
Returns
Type | Description |
---|---|
int | The index of the keyframe after moving it. |
Release()
Releases the internal texture resource.
Declaration
public void Release()
RemoveKey(int)
Removes a key.
Declaration
public void RemoveKey(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the key to remove. |
SetDirty()
Marks the curve as dirty to trigger a redraw of the texture the next time GetTexture() is called.
Declaration
public void SetDirty()
SmoothTangents(int, float)
Smoothes the in and out tangents of the keyframe at index
. A weight
of 0 evens out tangents.
Declaration
public void SmoothTangents(int index, float weight)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the keyframe to be smoothed. |
float | weight | The smoothing weight to apply to the keyframe's tangents. |