docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class MaterialUtils

    Runtime Material utilities.

    Inheritance
    object
    MaterialUtils
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.XR.CoreUtils
    Assembly: Unity.XR.CoreUtils.dll
    Syntax
    public static class MaterialUtils

    Methods

    AddMaterial(Renderer, Material)

    Adds a material to this renderer's array of shared materials.

    Declaration
    public static void AddMaterial(this Renderer renderer, Material material)
    Parameters
    Type Name Description
    Renderer renderer

    The renderer on which to add the material.

    Material material

    The material to add.

    CloneMaterials(Renderer)

    Clones and replaces all materials assigned to a Renderer

    Declaration
    public static Material[] CloneMaterials(Renderer renderer)
    Parameters
    Type Name Description
    Renderer renderer

    Renderer assigned the materials to clone and replace.

    Returns
    Type Description
    Material[]

    Cloned materials

    Remarks
    Warning

    You must call Destroy(Object, bool) on each cloned material object in the array when done.

    See Also
    materials

    GetMaterialClone(Renderer)

    Clones and replaces the material assigned to a Renderer.

    Declaration
    public static Material GetMaterialClone(Renderer renderer)
    Parameters
    Type Name Description
    Renderer renderer

    The renderer assigned the material to clone.

    Returns
    Type Description
    Material

    The cloned material.

    Remarks
    Warning

    You must call Destroy(Object, bool) on this material object when done.

    See Also
    material

    GetMaterialClone(Graphic)

    Clones and replaces the material assigned to a Graphic.

    Declaration
    public static Material GetMaterialClone(Graphic graphic)
    Parameters
    Type Name Description
    Graphic graphic

    The Graphic object assigned the material to clone.

    Returns
    Type Description
    Material

    Cloned material

    Remarks

    To use this function, your project must contain the Unity UI package (com.unity.ugui).

    Warning

    You must call Destroy(Object, bool) on this material object when done.

    See Also
    material

    HexToColor(string)

    Converts an RGB or RGBA formatted hex string to a Color object.

    Declaration
    public static Color HexToColor(string hex)
    Parameters
    Type Name Description
    string hex

    The formatted string, with an optional "0x" or "#" prefix.

    Returns
    Type Description
    Color

    The color value represented by the formatted string.

    HueShift(Color, float)

    Shift the hue of a color by a given amount.

    Declaration
    public static Color HueShift(Color color, float shift)
    Parameters
    Type Name Description
    Color color

    The input color.

    float shift

    The amount of shift.

    Returns
    Type Description
    Color

    The output color.

    Remarks

    The hue value wraps around to 0 if the shifted hue exceeds 1.0.

    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)