Class MaterialUtils | XR Tools Utilities | 1.0.0
docs.unity3d.com
    Show / Hide Table of Contents

    Class MaterialUtils

    Runtime Material utilities

    Inheritance
    Object
    MaterialUtils
    Namespace: Unity.XRTools.Utils
    Syntax
    public static class MaterialUtils

    Methods

    AddMaterial(Renderer, Material)

    Add a material to this renderer's 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 be added

    CloneMaterials(Renderer)

    Clone all materials within a renderer; IMPORTANT: Make sure to call UnityObjectUtils.Destroy() on this material when done!

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

    Renderer that will have its materials cloned and replaced

    Returns
    Type Description
    Material[]

    Cloned materials

    GetMaterialClone(Renderer)

    Get a material clone; IMPORTANT: Make sure to call UnityObjectUtils.Destroy() on this material when done!

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

    Renderer that will have its material clone and replaced

    Returns
    Type Description
    Material

    Cloned material

    GetMaterialClone(Graphic)

    Get a material clone; IMPORTANT: Make sure to call UnityObjectUtils.Destroy() on this material when done!

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

    Graphic that will have its material cloned and replaced

    Returns
    Type Description
    Material

    Cloned material

    HexToColor(String)

    Convert a formatted hex string to a Color

    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, Single)

    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

    Single shift

    The amount of shift

    Returns
    Type Description
    Color

    The output color

    SetRenderMode(Material, MaterialUtils.BlendMode)

    Set the render mode on the standard shader material. Adapted from StandardShaderGUI.SetupMaterialWithBlendMode

    Declaration
    public static void SetRenderMode(Material standardShaderMaterial, MaterialUtils.BlendMode blendMode)
    Parameters
    Type Name Description
    Material standardShaderMaterial

    The material to apply the rendering mode to.

    MaterialUtils.BlendMode blendMode

    The material rendering mode (opaque, cutout, fade, transparent)

    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