Skip to content

Commit

Permalink
feat: per-material opt-in for glTF material editing
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Sep 11, 2023
1 parent 6c8f0e8 commit 4fab674
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs
Expand Up @@ -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...
Expand Down

0 comments on commit 4fab674

Please sign in to comment.