Skip to content

Commit

Permalink
visually disable mesh property foldout content
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Jul 5, 2022
1 parent dfc8427 commit 326725f
Showing 1 changed file with 19 additions and 0 deletions.
Expand Up @@ -113,8 +113,10 @@ private void DrawGameObjectInfo(Material targetMaterial)
currentMaterialInfo.hasUV0 = mesh.HasVertexAttribute(VertexAttribute.TexCoord0);
currentMaterialInfo.hasUV1 = mesh.HasVertexAttribute(VertexAttribute.TexCoord1);

EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.ObjectField("Target Mesh", mesh, typeof(Mesh), true);
EditorGUILayout.Toggle("Has Vertex Colors", currentMaterialInfo.hasColor);
EditorGUI.EndDisabledGroup();

if (currentMaterialInfo.hasColor != targetMaterial.IsKeywordEnabled("_VERTEX_COLORS_ON"))
{
Expand All @@ -127,11 +129,28 @@ private void DrawGameObjectInfo(Material targetMaterial)
{
EditorGUILayout.HelpBox("Mesh has no vertex colors but Enable Vertex Colors is enabled.", MessageType.Info);
}

if (GUILayout.Button("Fix", EditorStyles.miniButtonRight, GUILayout.Width(50)))
{
if (currentMaterialInfo.hasColor)
{
targetMaterial.EnableKeyword("_VERTEX_COLORS_ON");
targetMaterial.SetFloat("_VERTEX_COLORS", 1);
}
else
{
targetMaterial.DisableKeyword("_VERTEX_COLORS_ON");
targetMaterial.SetFloat("_VERTEX_COLORS", 0);
}
}
EditorGUI.indentLevel--;
}

EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.Toggle("Has UV0", currentMaterialInfo.hasUV0);
EditorGUILayout.Toggle("Has UV1", currentMaterialInfo.hasUV1);
EditorGUI.EndDisabledGroup();

if (currentMaterialInfo.hasUV1 && targetMaterial.GetTexture("occlusionTexture"))
{
EditorGUI.indentLevel++;
Expand Down

0 comments on commit 326725f

Please sign in to comment.