TriLib Exporter
Search Results for

    Show / Hide Table of Contents

    Class MaterialExtensions

    Provides safe extension methods for Unity UnityEngine.Material objects, ensuring no exceptions are thrown if properties are missing.

    Inheritance
    object
    MaterialExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: TriLibExporter
    Assembly: Assembly-CSharp.dll
    Syntax
    public static class MaterialExtensions

    Methods

    GetColorSafe(Material, string)

    Safely retrieves a color property from a material.

    Declaration
    public static Color GetColorSafe(this Material material, string name)
    Parameters
    Type Name Description
    Material material

    The material to query.

    string name

    The name of the color property.

    Returns
    Type Description
    Color

    The color value if it exists; otherwise, the default color.

    GetFloatSafe(Material, string)

    Safely retrieves a float property from a material.

    Declaration
    public static float GetFloatSafe(this Material material, string name)
    Parameters
    Type Name Description
    Material material

    The material to query.

    string name

    The name of the float property.

    Returns
    Type Description
    float

    The float value if it exists; otherwise, the default float value.

    GetTextureSafe(Material, string)

    Safely retrieves a texture property from a material.

    Declaration
    public static Texture GetTextureSafe(this Material material, string name)
    Parameters
    Type Name Description
    Material material

    The material to query.

    string name

    The name of the texture property.

    Returns
    Type Description
    Texture

    The texture if it exists; otherwise, null.

    GetVectorSafe(Material, string)

    Safely retrieves a vector property from a material.

    Declaration
    public static Vector4 GetVectorSafe(this Material material, string name)
    Parameters
    Type Name Description
    Material material

    The material to query.

    string name

    The name of the vector property.

    Returns
    Type Description
    Vector4

    The vector value if it exists; otherwise, the default vector.

    In this article
    Back to top Generated by DocFX