docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TMP_MaterialManager

    Inheritance
    object
    TMP_MaterialManager
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: TMPro
    Assembly: Unity.TextMeshPro.dll
    Syntax
    public static class TMP_MaterialManager

    Methods

    AddFallbackMaterialReference(Material)

    Registers a fallback material reference for tracking and cleanup.

    Declaration
    public static void AddFallbackMaterialReference(Material targetMaterial)
    Parameters
    Type Name Description
    Material targetMaterial

    The fallback material to add a reference for.

    AddMaskingMaterial(Material, Material, int)

    Declaration
    public static void AddMaskingMaterial(Material baseMaterial, Material stencilMaterial, int stencilID)
    Parameters
    Type Name Description
    Material baseMaterial
    Material stencilMaterial
    int stencilID

    CleanupFallbackMaterials()

    Destroys fallback materials that have no remaining references and clears the cleanup list.

    Declaration
    public static void CleanupFallbackMaterials()

    ClearMaterials()

    Declaration
    public static void ClearMaterials()

    CopyMaterialPresetProperties(Material, Material)

    Copies the properties of a source material preset to a destination while preserving the destination's unique font asset properties.

    Declaration
    public static void CopyMaterialPresetProperties(Material source, Material destination)
    Parameters
    Type Name Description
    Material source

    The source material to copy properties from.

    Material destination

    The destination material to copy properties to.

    GetBaseMaterial(Material)

    Declaration
    public static Material GetBaseMaterial(Material stencilMaterial)
    Parameters
    Type Name Description
    Material stencilMaterial
    Returns
    Type Description
    Material

    GetFallbackMaterial(Material, Material)

    This function returns a material instance using the material properties of a previous material but using the font atlas texture of the new font asset.

    Declaration
    public static Material GetFallbackMaterial(Material sourceMaterial, Material targetMaterial)
    Parameters
    Type Name Description
    Material sourceMaterial

    The material containing the source material properties to be copied to the new material.

    Material targetMaterial

    The font atlas texture that should be assigned to the new material.

    Returns
    Type Description
    Material

    A material instance with source properties and target material's main texture.

    GetMaterialForRendering(MaskableGraphic, Material)

    Declaration
    public static Material GetMaterialForRendering(MaskableGraphic graphic, Material baseMaterial)
    Parameters
    Type Name Description
    MaskableGraphic graphic
    Material baseMaterial
    Returns
    Type Description
    Material

    GetStencilID(GameObject)

    Gets the combined stencil ID from mask components above the object.

    Declaration
    public static int GetStencilID(GameObject obj)
    Parameters
    Type Name Description
    GameObject obj

    The GameObject to get the stencil ID for (from Mask components in the hierarchy).

    Returns
    Type Description
    int

    The combined stencil ID from all masks above the object.

    GetStencilMaterial(Material, int)

    Creates a masking material instance for the given ID.

    Declaration
    public static Material GetStencilMaterial(Material baseMaterial, int stencilID)
    Parameters
    Type Name Description
    Material baseMaterial

    The base material to create a stencil masking instance from.

    int stencilID

    The stencil ID to assign to the masking material.

    Returns
    Type Description
    Material

    A material instance configured for stencil masking with the given ID.

    ReleaseBaseMaterial(Material)

    Declaration
    public static void ReleaseBaseMaterial(Material baseMaterial)
    Parameters
    Type Name Description
    Material baseMaterial

    ReleaseFallbackMaterial(Material)

    Function to release the fallback material.

    Declaration
    public static void ReleaseFallbackMaterial(Material fallbackMaterial)
    Parameters
    Type Name Description
    Material fallbackMaterial

    Material to be released.

    ReleaseStencilMaterial(Material)

    Releases the stencil material (decrements reference count or destroys if last).

    Declaration
    public static void ReleaseStencilMaterial(Material stencilMaterial)
    Parameters
    Type Name Description
    Material stencilMaterial

    The stencil material to release (decrements reference count or destroys if last).

    RemoveFallbackMaterialReference(Material)

    Decrements the reference count for a fallback material; when the count reaches zero it is queued for cleanup.

    Declaration
    public static void RemoveFallbackMaterialReference(Material targetMaterial)
    Parameters
    Type Name Description
    Material targetMaterial

    The fallback material whose reference count should be decremented.

    RemoveStencilMaterial(Material)

    Declaration
    public static void RemoveStencilMaterial(Material stencilMaterial)
    Parameters
    Type Name Description
    Material stencilMaterial

    SetStencil(Material, int)

    Sets the stencil ID on the material.

    Declaration
    public static Material SetStencil(Material material, int stencilID)
    Parameters
    Type Name Description
    Material material

    The material to set the stencil ID on.

    int stencilID

    The stencil ID value to assign to the material for masking.

    Returns
    Type Description
    Material

    The same material with stencil ID applied.

    In This Article
    Back to top
    Copyright © 2026 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)