Class TextureCurve | Core RP Library | 7.2.1
docs.unity3d.com
    Show / Hide Table of Contents

    Class TextureCurve

    A wrapper around AnimationCurve to automatically bake it into a texture.

    Inheritance
    Object
    TextureCurve
    Namespace: UnityEngine.Rendering
    Syntax
    [Serializable]
    public class TextureCurve : IDisposable

    Constructors

    TextureCurve(AnimationCurve, Single, Boolean, 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 AnimationCurve.

    Single zeroValue

    The default value to use when the curve doesn't have any key.

    Boolean loop

    Should the curve automatically loop in the given bounds?

    Vector2 bounds

    The boundaries of the curve.

    TextureCurve(Keyframe[], Single, Boolean, 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.

    Single zeroValue

    The default value to use when the curve doesn't have any key.

    Boolean loop

    Should the curve automatically loop in the given bounds?

    Vector2 bounds

    The boundaries of the curve.

    Properties

    Item[Int32]

    Retrieves the key at index.

    Declaration
    public Keyframe this[int index] { get; }
    Parameters
    Type Name Description
    Int32 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
    Int32

    Methods

    AddKey(Single, Single)

    Adds a new key to the curve.

    Declaration
    public int AddKey(float time, float value)
    Parameters
    Type Name Description
    Single time

    The time at which to add the key.

    Single value

    The value for the key.

    Returns
    Type Description
    Int32

    The index of the added key, or -1 if the key could not be added.

    Dispose()

    Cleans up the internal texture resource.

    Declaration
    public void Dispose()

    Evaluate(Single)

    Evaluate a time value on the curve.

    Declaration
    public float Evaluate(float time)
    Parameters
    Type Name Description
    Single time

    The time within the curve you want to evaluate.

    Returns
    Type Description
    Single

    The value of the curve, at the point in time specified.

    Finalize()

    Finalizer.

    Declaration
    protected void Finalize()

    GetTexture()

    Gets the texture representation of this curve.

    Declaration
    public Texture2D GetTexture()
    Returns
    Type Description
    Texture2D

    A 128x1 texture.

    MoveKey(Int32, Keyframe)

    Removes the keyframe at index and inserts key.

    Declaration
    public int MoveKey(int index, in Keyframe key)
    Parameters
    Type Name Description
    Int32 index
    Keyframe key
    Returns
    Type Description
    Int32

    The index of the keyframe after moving it.

    RemoveKey(Int32)

    Removes a key.

    Declaration
    public void RemoveKey(int index)
    Parameters
    Type Name Description
    Int32 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(Int32, Single)

    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
    Int32 index

    The index of the keyframe to be smoothed.

    Single weight

    The smoothing weight to apply to the keyframe's tangents.

    In This Article
    • Constructors
      • TextureCurve(AnimationCurve, Single, Boolean, Vector2)
      • TextureCurve(Keyframe[], Single, Boolean, Vector2)
    • Properties
      • Item[Int32]
      • length
    • Methods
      • AddKey(Single, Single)
      • Dispose()
      • Evaluate(Single)
      • Finalize()
      • GetTexture()
      • MoveKey(Int32, Keyframe)
      • RemoveKey(Int32)
      • SetDirty()
      • SmoothTangents(Int32, Single)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023