From 1d0b485b02ed4d6c0de0f761acc8af653eb4b577 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 17 Mar 2021 19:23:56 +0900 Subject: [PATCH] rename material --- Assets/UniGLTF/Runtime/UniGLTF/IO/GltfParser.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfParser.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfParser.cs index c53a9c105..3f706f4e0 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfParser.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfParser.cs @@ -275,11 +275,17 @@ namespace UniGLTF public void FixMaterialNameUnique() { var used = new HashSet(); - foreach (var material in GLTF.materials) + for (int i = 0; i < GLTF.materials.Count; ++i) { + var material = GLTF.materials[i]; var originalName = material.name; int j = 2; + if (string.IsNullOrEmpty(material.name)) + { + material.name = $"material_{i}"; + } + while (true) { if (used.Add(material.name))