From 4fab6741698e20d5e2910b772c42426db0bc0493 Mon Sep 17 00:00:00 2001 From: hybridherbst Date: Mon, 11 Sep 2023 09:02:23 +0200 Subject: [PATCH] feat: per-material opt-in for glTF material editing --- .../ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs b/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs index d14390673..683a6456f 100644 --- a/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs +++ b/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs @@ -67,7 +67,19 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro if (immutableMaterialCanBeModified) { GUI.enabled = true; - EditorGUILayout.HelpBox("(Experimental) This material is part of a glTF asset. Changes will be stored back to the .glTF file when saving.", MessageType.Warning); + EditorGUILayout.HelpBox("This material is part of a glTF asset. If you enable editing (experimental), changes will be stored back to the .glTF file when saving.", MessageType.None); + + var materialEditingKey = nameof(PBRGraphGUI) + ".AllowGltfMaterialEditing." + targetMat.GetInstanceID(); + var isAllowed = SessionState.GetBool(materialEditingKey, false); + var allowMaterialEditing = EditorGUILayout.Toggle("Allow Editing", isAllowed); + if (allowMaterialEditing != isAllowed) + SessionState.SetBool(materialEditingKey, allowMaterialEditing); + + if (allowMaterialEditing) + EditorGUILayout.HelpBox("glTF editing is enabled. This is highly experimental. Make sure you have a backup!", MessageType.Warning); + + GUI.enabled = allowMaterialEditing; + EditorGUILayout.Space(); } // Need to set these via reflection...