Skip to content

Commit

Permalink
feat: allow enabling GPU instancing directly from the material importer
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Dec 13, 2023
1 parent 803511e commit 8ef4958
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Editor/Scripts/GLTFImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private static void EnsureShadersAreLoaded()
[SerializeField] internal bool _animationLoopTime = true;
[SerializeField] internal bool _animationLoopPose = false;
[SerializeField] internal bool _importMaterials = true;
[SerializeField] internal bool _enableGpuInstancing = false;
[Tooltip("Enable this to get the same main asset identifiers as glTFast uses. This is recommended for new asset imports. Note that changing this for already imported assets will break their scene references and require manually re-adding the affected assets.")]
[SerializeField] internal bool _useSceneNameIdentifier = false;
[Tooltip("Compress textures after import using the platform default settings. If you need more control, use a .gltf file instead.")]
Expand Down Expand Up @@ -482,6 +483,7 @@ string GetUniqueName(string desiredName)
}

mat.name = matName;
mat.enableInstancing = _enableGpuInstancing;
materials.Add(mat);
}
}
Expand Down
9 changes: 8 additions & 1 deletion Editor/Scripts/GLTFImporterInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@ private void MaterialInspectorGUI()
var t = target as GLTFImporter;
if (!t) return;

EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._importMaterials)));
var importMaterialsProp = serializedObject.FindProperty(nameof(GLTFImporter._importMaterials));
EditorGUILayout.PropertyField(importMaterialsProp);
if (importMaterialsProp.boolValue)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._enableGpuInstancing)), new GUIContent("GPU Instancing"));
EditorGUI.indentLevel--;
}
var importedMaterials = serializedObject.FindProperty("m_Materials");
if (importedMaterials.arraySize > 0)
{
Expand Down

0 comments on commit 8ef4958

Please sign in to comment.