docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GradientUtility

    Utility to facilitate an efficient interpolation between two gradients.

    Inheritance
    object
    GradientUtility
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.XR.Interaction.Toolkit.Utilities
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    public class GradientUtility

    Methods

    CopyGradient(Gradient, Gradient)

    Copies the color and alpha keys from a source Gradient to a destination Gradient.

    Declaration
    public static void CopyGradient(Gradient source, Gradient destination)
    Parameters
    Type Name Description
    Gradient source

    The Gradient to copy from.

    Gradient destination

    The Gradient to copy to. This Gradient is modified by this method.

    Lerp(Gradient, Gradient, float, bool, bool)

    Linearly interpolates between two gradients with options to independently skip color or alpha interpolation.

    Declaration
    public static Gradient Lerp(Gradient a, Gradient b, float t, bool lerpColors = true, bool lerpAlphas = true)
    Parameters
    Type Name Description
    Gradient a

    The first gradient.

    Gradient b

    The second gradient.

    float t

    Interpolation factor (0 to 1).

    bool lerpColors

    If true, interpolate colors; otherwise, use colors from gradient b.

    bool lerpAlphas

    If true, interpolate alphas; otherwise, use alphas from gradient b.

    Returns
    Type Description
    Gradient

    Returns the interpolated gradient as a new gradient instance.

    Remarks

    This method allocates a new Gradient instance for the interpolated result. Consider using the other Lerp method to provide a pre-allocated Gradient instance to avoid GC allocations.

    Lerp(Gradient, Gradient, Gradient, float, bool, bool)

    Linearly interpolates between two gradients with options to independently skip color or alpha interpolation.

    Declaration
    public static void Lerp(Gradient a, Gradient b, Gradient output, float t, bool lerpColors = true, bool lerpAlphas = true)
    Parameters
    Type Name Description
    Gradient a

    The first gradient.

    Gradient b

    The second gradient.

    Gradient output

    The interpolated gradient.

    float t

    Interpolation factor (0 to 1).

    bool lerpColors

    If true, interpolate colors; otherwise, use colors from gradient b.

    bool lerpAlphas

    If true, interpolate alphas; otherwise, use alphas from gradient b.

    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)