From 326725f7d68f9aa4194f8213b2d03ddd6f8fc5d6 Mon Sep 17 00:00:00 2001 From: Felix Herbst Date: Wed, 6 Jul 2022 00:15:40 +0200 Subject: [PATCH] visually disable mesh property foldout content --- .../InternalShaderGraph/PBRGraphGUI.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/UnityGLTF/Assets/UnityGLTF/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs b/UnityGLTF/Assets/UnityGLTF/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs index 71cd79072..edd13afaf 100644 --- a/UnityGLTF/Assets/UnityGLTF/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs +++ b/UnityGLTF/Assets/UnityGLTF/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs @@ -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")) { @@ -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++;