Search Results for

    Show / Hide Table of Contents

    Class CustomizableMaterialMapper

    A customizable material mapper for converting source materials into Unity materials during runtime model importing.

    Inheritance
    object
    Object
    ScriptableObject
    MaterialMapper
    CustomizableMaterialMapper
    Inherited Members
    MaterialMapper.CheckingOrder
    MaterialMapper.DisableAlpha
    MaterialMapper.RegisteredMapperNamespaces
    MaterialMapper.RegisteredMappers
    MaterialMapper.ApplyMaterialToRenderer(MaterialRendererContext)
    MaterialMapper.Cleanup(MaterialRendererContext)
    MaterialMapper.GetGlossinessOrRoughnessName(MaterialMapperContext)
    MaterialMapper.Map(MaterialMapperContext)
    MaterialMapper.ConvertMaterialColor(MaterialMapperContext, Color)
    MaterialMapper.CheckTextureOffsetAndScaling(TextureLoadingContext)
    MaterialMapper.CheckTextureOffsetAndScaling(MaterialMapperContext, ITexture, bool)
    MaterialMapper.CheckTextureOffsetAndScalingCoroutine(TextureLoadingContext)
    MaterialMapper.BuildMaterial(MaterialMapperContext)
    MaterialMapper.LoadTextureWithCallbacks(MaterialMapperContext, TextureType, ITexture, params Action<TextureLoadingContext>[])
    MaterialMapper.LoadTextureWithCoroutineCallbacks(MaterialMapperContext, TextureType, ITexture, params Func<TextureLoadingContext, IEnumerable>[])
    Namespace: TriLibCore.Mappers
    Assembly: TriLibCore.dll
    Syntax
    [Serializable]
    [CreateAssetMenu(menuName = "TriLib/Mappers/Material/Customizable Material Mapper", fileName = "CustomizableMaterialMapper")]
    public class CustomizableMaterialMapper : MaterialMapper

    Fields

    CurrentVersion

    The current data layout version. Bump this whenever the slot layout of TriLibCore.Mappers.CustomizableMaterialMapper._values/TriLibCore.Mappers.CustomizableMaterialMapper._keywords changes.

    Declaration
    public const int CurrentVersion = 1
    Field Value
    Type Description
    int

    GenericPropertiesCount

    The number of generic material properties supported by this mapper.

    Declaration
    public const int GenericPropertiesCount = 21
    Field Value
    Type Description
    int

    GenericPropertyIndices

    Array mapping generic material properties to their corresponding indices.

    Declaration
    public static int[] GenericPropertyIndices
    Field Value
    Type Description
    int[]

    GenericPropertyToIndex

    Maps a GenericMaterialProperty value to its index inside GenericPropertyIndices. Unused enum values contain -1.

    Declaration
    public static int[] GenericPropertyToIndex
    Field Value
    Type Description
    int[]

    MigrationPendingSave

    Indicates whether a legacy migration ran on this instance since it was deserialized. The editor uses this to know it must re-save the asset.

    Declaration
    [NonSerialized]
    public bool MigrationPendingSave
    Field Value
    Type Description
    bool

    Properties

    ConvertMaterialTextures

    Gets whether material textures should be converted.

    Declaration
    public override bool ConvertMaterialTextures { get; }
    Property Value
    Type Description
    bool
    Overrides
    MaterialMapper.ConvertMaterialTextures

    CutoutMaterialPreset

    Gets the cutout material preset.

    Declaration
    public override Material CutoutMaterialPreset { get; }
    Property Value
    Type Description
    Material
    Overrides
    MaterialMapper.CutoutMaterialPreset

    CutoutMaterialPresetNoMetallicTexture

    Gets the cutout material preset without metallic textures.

    Declaration
    public override Material CutoutMaterialPresetNoMetallicTexture { get; }
    Property Value
    Type Description
    Material
    Overrides
    MaterialMapper.CutoutMaterialPresetNoMetallicTexture

    ExtractMetallicAndSmoothness

    Gets whether metallic and smoothness values should be extracted.

    Declaration
    public override bool ExtractMetallicAndSmoothness { get; }
    Property Value
    Type Description
    bool
    Overrides
    MaterialMapper.ExtractMetallicAndSmoothness

    LoadingMaterial

    The material to use while the Material Mapper is processing.

    Declaration
    public override Material LoadingMaterial { get; }
    Property Value
    Type Description
    Material
    Overrides
    MaterialMapper.LoadingMaterial

    MaterialPreset

    Gets the default material preset.

    Declaration
    public override Material MaterialPreset { get; }
    Property Value
    Type Description
    Material
    Overrides
    MaterialMapper.MaterialPreset

    MaterialPresetNoMetallicTexture

    Gets the material preset without metallic textures.

    Declaration
    public override Material MaterialPresetNoMetallicTexture { get; }
    Property Value
    Type Description
    Material
    Overrides
    MaterialMapper.MaterialPresetNoMetallicTexture

    TransparentComposeMaterialPreset

    Gets the transparent compose material preset.

    Declaration
    public override Material TransparentComposeMaterialPreset { get; }
    Property Value
    Type Description
    Material
    Overrides
    MaterialMapper.TransparentComposeMaterialPreset

    TransparentComposeMaterialPresetNoMetallicTexture

    Gets the transparent compose material preset without metallic textures.

    Declaration
    public override Material TransparentComposeMaterialPresetNoMetallicTexture { get; }
    Property Value
    Type Description
    Material
    Overrides
    MaterialMapper.TransparentComposeMaterialPresetNoMetallicTexture

    TransparentMaterialPreset

    Gets the transparent material preset.

    Declaration
    public override Material TransparentMaterialPreset { get; }
    Property Value
    Type Description
    Material
    Overrides
    MaterialMapper.TransparentMaterialPreset

    TransparentMaterialPresetNoMetallicTexture

    Gets the transparent material preset without metallic textures.

    Declaration
    public override Material TransparentMaterialPresetNoMetallicTexture { get; }
    Property Value
    Type Description
    Material
    Overrides
    MaterialMapper.TransparentMaterialPresetNoMetallicTexture

    UseShaderVariantCollection

    Gets whether to use a shader variant collection.

    Declaration
    public override bool UseShaderVariantCollection { get; }
    Property Value
    Type Description
    bool
    Overrides
    MaterialMapper.UseShaderVariantCollection

    UsesCoroutines

    Gets whether this mapper uses coroutines for asynchronous processing.

    Declaration
    public override bool UsesCoroutines { get; }
    Property Value
    Type Description
    bool
    Overrides
    MaterialMapper.UsesCoroutines

    Methods

    ApplyDiffuseMapTexture(TextureLoadingContext)

    Applies a diffuse map texture to the material.

    Declaration
    protected virtual IEnumerable ApplyDiffuseMapTexture(TextureLoadingContext textureLoadingContext)
    Parameters
    Type Name Description
    TextureLoadingContext textureLoadingContext

    The texture loading context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    ApplyDisplacementTexture(TextureLoadingContext)

    Applies a displacement texture to the material.

    Declaration
    protected virtual IEnumerable ApplyDisplacementTexture(TextureLoadingContext textureLoadingContext)
    Parameters
    Type Name Description
    TextureLoadingContext textureLoadingContext

    The texture loading context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    ApplyEmissionMapTexture(TextureLoadingContext)

    Applies an emission map texture to the material.

    Declaration
    protected virtual IEnumerable ApplyEmissionMapTexture(TextureLoadingContext textureLoadingContext)
    Parameters
    Type Name Description
    TextureLoadingContext textureLoadingContext

    The texture loading context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    ApplyGlossinessMapTexture(TextureLoadingContext)

    Applies a glossiness or roughness map texture to the material.

    Declaration
    protected virtual IEnumerable ApplyGlossinessMapTexture(TextureLoadingContext textureLoadingContext)
    Parameters
    Type Name Description
    TextureLoadingContext textureLoadingContext

    The texture loading context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    ApplyKeywords(MaterialMapperContext, GenericMaterialProperty)

    Applies shader keywords for a given material property.

    Declaration
    protected virtual void ApplyKeywords(MaterialMapperContext materialMapperContext, GenericMaterialProperty genericMaterialProperty)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    GenericMaterialProperty genericMaterialProperty

    The generic material property.

    ApplyMetallicGlossMapTexture(TextureLoadingContext)

    Applies a metallic gloss map texture to the material.

    Declaration
    protected virtual IEnumerable ApplyMetallicGlossMapTexture(TextureLoadingContext textureLoadingContext)
    Parameters
    Type Name Description
    TextureLoadingContext textureLoadingContext

    The texture loading context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    ApplyNormalMapTexture(TextureLoadingContext)

    Applies a normal map texture to the material.

    Declaration
    protected virtual IEnumerable ApplyNormalMapTexture(TextureLoadingContext textureLoadingContext)
    Parameters
    Type Name Description
    TextureLoadingContext textureLoadingContext

    The texture loading context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    ApplyOcclusionMapTexture(TextureLoadingContext)

    Applies an occlusion map texture to the material.

    Declaration
    protected virtual IEnumerable ApplyOcclusionMapTexture(TextureLoadingContext textureLoadingContext)
    Parameters
    Type Name Description
    TextureLoadingContext textureLoadingContext

    The texture loading context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    ApplySpecularMapTexture(TextureLoadingContext)

    Applies a specular map texture to the material.

    Declaration
    protected virtual IEnumerable ApplySpecularMapTexture(TextureLoadingContext textureLoadingContext)
    Parameters
    Type Name Description
    TextureLoadingContext textureLoadingContext

    The texture loading context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    ApplyTexture(TextureLoadingContext, GenericMaterialProperty)

    Applies a texture to the material for a specific generic property.

    Declaration
    protected virtual void ApplyTexture(TextureLoadingContext textureLoadingContext, GenericMaterialProperty genericMaterialProperty)
    Parameters
    Type Name Description
    TextureLoadingContext textureLoadingContext

    The texture loading context.

    GenericMaterialProperty genericMaterialProperty

    The generic material property.

    ApplyTransparencyMapTexture(TextureLoadingContext)

    Applies a transparency map texture to the material.

    Declaration
    protected virtual IEnumerable ApplyTransparencyMapTexture(TextureLoadingContext textureLoadingContext)
    Parameters
    Type Name Description
    TextureLoadingContext textureLoadingContext

    The texture loading context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckDiffuseColor(MaterialMapperContext)

    Checks and applies the diffuse color to the material.

    Declaration
    protected virtual IEnumerable CheckDiffuseColor(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckDiffuseMapTexture(MaterialMapperContext)

    Checks and loads the diffuse map texture.

    Declaration
    protected virtual IEnumerable CheckDiffuseMapTexture(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckDisplacementTexture(MaterialMapperContext)

    Checks and loads the displacement texture.

    Declaration
    protected virtual IEnumerable CheckDisplacementTexture(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckEmissionColor(MaterialMapperContext)

    Checks and applies the emission color to the material.

    Declaration
    protected virtual IEnumerable CheckEmissionColor(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckEmissionMapTexture(MaterialMapperContext)

    Checks and loads the emission map texture.

    Declaration
    protected virtual IEnumerable CheckEmissionMapTexture(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckGlossinessMapTexture(MaterialMapperContext)

    Checks and loads the glossiness or roughness map texture.

    Declaration
    protected virtual IEnumerable CheckGlossinessMapTexture(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckGlossinessValue(MaterialMapperContext)

    Checks and applies the glossiness or roughness value to the material.

    Declaration
    protected virtual IEnumerable CheckGlossinessValue(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckMetallicGlossMapTexture(MaterialMapperContext)

    Checks and loads the metallic gloss map texture.

    Declaration
    protected virtual IEnumerable CheckMetallicGlossMapTexture(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckMetallicValue(MaterialMapperContext)

    Checks and applies the metallic value to the material.

    Declaration
    protected virtual IEnumerable CheckMetallicValue(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckNormalMapTexture(MaterialMapperContext)

    Checks and loads the normal map texture.

    Declaration
    protected virtual IEnumerable CheckNormalMapTexture(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckOcclusionMapTexture(MaterialMapperContext)

    Checks and loads the occlusion map texture.

    Declaration
    protected virtual IEnumerable CheckOcclusionMapTexture(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckSpecularMapTexture(MaterialMapperContext)

    Checks and loads the specular map texture.

    Declaration
    protected virtual IEnumerable CheckSpecularMapTexture(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    CheckTransparencyMapTexture(MaterialMapperContext)

    Checks and loads the transparency map texture.

    Declaration
    protected virtual IEnumerable CheckTransparencyMapTexture(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    GetDiffuseColorName(MaterialMapperContext)

    Gets the shader property name for the diffuse color.

    Declaration
    public override string GetDiffuseColorName(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    string

    The shader property name for the diffuse color.

    Overrides
    MaterialMapper.GetDiffuseColorName(MaterialMapperContext)

    GetDiffuseTextureName(MaterialMapperContext)

    Gets the shader property name for the diffuse texture.

    Declaration
    public override string GetDiffuseTextureName(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    string

    The shader property name for the diffuse texture.

    Overrides
    MaterialMapper.GetDiffuseTextureName(MaterialMapperContext)

    GetEmissionColorName(MaterialMapperContext)

    Gets the shader property name for the emission color.

    Declaration
    public override string GetEmissionColorName(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    string

    The shader property name for the emission color.

    Overrides
    MaterialMapper.GetEmissionColorName(MaterialMapperContext)

    GetGlossinessOrRoughnessName(MaterialMapperContext, bool)

    Gets the shader property name for glossiness or roughness.

    Declaration
    public override string GetGlossinessOrRoughnessName(MaterialMapperContext materialMapperContext, bool hasTexture)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    bool hasTexture

    Some Unity shaders use different property names for glossiness/roughness depending whether there is a glossiness/roughness texture on the material, or not. Use this parameter to handle these cases.

    Returns
    Type Description
    string

    The shader property name for glossiness or roughness.

    Overrides
    MaterialMapper.GetGlossinessOrRoughnessName(MaterialMapperContext, bool)

    GetGlossinessOrRoughnessTextureName(MaterialMapperContext)

    Gets the shader property name for the glossiness or roughness texture.

    Declaration
    public override string GetGlossinessOrRoughnessTextureName(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    string

    The shader property name for the glossiness or roughness texture.

    Overrides
    MaterialMapper.GetGlossinessOrRoughnessTextureName(MaterialMapperContext)

    GetMappedProperty(GenericMaterialProperty)

    Gets the mapped shader property name for a generic material property.

    Declaration
    protected virtual string GetMappedProperty(GenericMaterialProperty genericMaterialProperty)
    Parameters
    Type Name Description
    GenericMaterialProperty genericMaterialProperty

    The generic material property.

    Returns
    Type Description
    string

    The mapped shader property name.

    GetMaterialPreset(Material)

    Gets the material preset, falling back to the default preset if none is specified.

    Declaration
    protected virtual Material GetMaterialPreset(Material materialPreset)
    Parameters
    Type Name Description
    Material materialPreset

    The material preset to use.

    Returns
    Type Description
    Material

    The selected material preset.

    GetMetallicName(MaterialMapperContext)

    Gets the shader property name for the metallic value.

    Declaration
    public override string GetMetallicName(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    string

    The shader property name for the metallic value.

    Overrides
    MaterialMapper.GetMetallicName(MaterialMapperContext)

    GetMetallicTextureName(MaterialMapperContext)

    Gets the shader property name for the metallic texture.

    Declaration
    public override string GetMetallicTextureName(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    string

    The shader property name for the metallic texture.

    Overrides
    MaterialMapper.GetMetallicTextureName(MaterialMapperContext)

    IsCompatible(MaterialMapperContext)

    Determines if this mapper is compatible with the provided material context.

    Declaration
    public override bool IsCompatible(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    bool

    True if compatible, otherwise false.

    Overrides
    MaterialMapper.IsCompatible(MaterialMapperContext)

    MapCoroutine(MaterialMapperContext)

    Maps material properties using coroutines for asynchronous processing.

    Declaration
    public override IEnumerable MapCoroutine(MaterialMapperContext materialMapperContext)
    Parameters
    Type Name Description
    MaterialMapperContext materialMapperContext

    The material mapping context.

    Returns
    Type Description
    IEnumerable

    An enumerable of coroutine steps.

    Overrides
    MaterialMapper.MapCoroutine(MaterialMapperContext)

    MigrateLegacyData()

    Migrates legacy serialized data (20-slot layout) into the current layout. Safe to call multiple times. Returns true when data was actually changed.

    Declaration
    public bool MigrateLegacyData()
    Returns
    Type Description
    bool

    OnAfterDeserialize()

    Implement this method to receive a callback after Unity deserializes your object.

    Declaration
    public void OnAfterDeserialize()

    OnBeforeSerialize()

    Implement this method to receive a callback before Unity serializes your object.

    Declaration
    public void OnBeforeSerialize()

    Extension Methods

    IObjectExtensions.TryToDispose<T>(object)
    In this article
    Back to top TriLib documentation