Skip to content

Commit

Permalink
add material creation menu and note about glTF editing being experime…
Browse files Browse the repository at this point in the history
…ntal
  • Loading branch information
hybridherbst committed Aug 26, 2023
1 parent 992e24e commit b14bb02
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
22 changes: 22 additions & 0 deletions Editor/Scripts/GLTFExportMenu.cs
Expand Up @@ -131,4 +131,26 @@ private static void Export(Transform[] transforms, bool binary, string sceneName
}
}
}

internal static class GLTFCreateMenu
{
[MenuItem("Assets/Create/UnityGLTF/Material", false)]
private static void CreateNewAsset()
{
ProjectWindowUtil.CreateAssetWithContent("New glTF Material.gltf", @"{
""asset"": {
""generator"": ""UnityGLTF"",
""version"": ""2.0""
},
""materials"": [
{
""name"": ""Material"",
""pbrMetallicRoughness"": {
""metallicFactor"": 0.0
}
}
]
}");
}
}
}
Expand Up @@ -65,9 +65,12 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
// Force GUI changes to be allowed, despite being in an immutable context.
// We can store the changes back to .glTF when saving.
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);
}

// Need to set these via reflection...
// Need to set these via reflection...
// m_MaterialEditor = materialEditor;
// m_Properties = properties;
if (m_MaterialEditor == null) m_MaterialEditor = typeof(BuiltInBaseShaderGUI).GetField(nameof(m_MaterialEditor), BindingFlags.Instance | BindingFlags.NonPublic);
Expand Down

0 comments on commit b14bb02

Please sign in to comment.