diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfParser.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfParser.cs index 840ce980c..020337717 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfParser.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfParser.cs @@ -204,12 +204,32 @@ namespace UniGLTF } } + void RenameImageFromTexture(int i) + { + foreach (var texture in GLTF.textures) + { + if (texture.source == i) + { + if (!string.IsNullOrEmpty(texture.name)) + { + GLTF.images[i].name = texture.name; + return; + } + } + } + } + void FixImageNameUnique() { var used = new HashSet(); for (int i = 0; i < GLTF.images.Count; ++i) { var image = GLTF.images[i]; + if (string.IsNullOrEmpty(image.name)) + { + RenameImageFromTexture(i); + } + if (string.IsNullOrEmpty(image.name)) { var newName = $"image_{i}";