public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
FindOptionProperties(props);
layerMaskMapProperty = FindProperty(kLayerMaskMap, props);
layerCountProperty = FindProperty(kLayerCount, props);
m_MaterialEditor = materialEditor;
m_MaterialEditor.serializedObject.Update();
Material material = m_MaterialEditor.target as Material;
AssetImporter materialImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(material.GetInstanceID()));
InitializeMaterialLayers(materialImporter);
bool optionsChanged = false;
EditorGUI.BeginChangeCheck();
{
ShaderOptionsGUI();
EditorGUILayout.Space();
}
if (EditorGUI.EndChangeCheck())
{
optionsChanged = true;
}
bool layerChanged = LayersGUI(materialImporter);
CheckLayerConsistency();
if (layerChanged || optionsChanged)
{
SynchronizeInputOptions();
foreach (var obj in m_MaterialEditor.targets)
{
SetupMaterial((Material)obj);
SetupMaterialForLayers((Material)obj);
}
SaveMaterialLayers(materialImporter);
}
m_MaterialEditor.serializedObject.ApplyModifiedProperties();
if (layerChanged)
{
materialImporter.SaveAndReimport();
}
}