From 5447d2a67eaaf282bfc59e6b695d0bf9cee3e0f8 Mon Sep 17 00:00:00 2001 From: hiroj Date: Wed, 28 Apr 2021 13:34:50 +0900 Subject: [PATCH] =?UTF-8?q?fix=E3=80=80none=E3=80=80vertex=E3=80=80mesh?= =?UTF-8?q?=E3=80=80export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/UniGLTF/IO/gltfExporter.cs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs index f8e42179d..3c0abf80e 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs @@ -160,6 +160,11 @@ namespace UniGLTF { node.mesh = meshIndex; } + else if(mesh != null && !mesh.vertices.Any()) + { + // 頂点データが無い場合 + node.mesh = -1; + } else { // MeshとMaterialが一致するものが見つからなかった @@ -178,6 +183,11 @@ namespace UniGLTF node.mesh = meshIndex; node.skin = skins.IndexOf(skinnedMeshRenderer); } + else if (mesh != null && !mesh.vertices.Any()) + { + // 頂点データが無い場合 + node.mesh = -1; + } else { // MeshとMaterialが一致するものが見つからなかった @@ -218,8 +228,15 @@ namespace UniGLTF .Skip(1) // exclude root object for the symmetry with the importer .ToList(); + var unityMeshes = MeshWithRenderer.FromNodes(Nodes).Where(x => x.Mesh.vertices.Any()).ToList(); + var uniqueUnityMeshes = new List(); + foreach (var um in unityMeshes) + { + if (!uniqueUnityMeshes.Any(x => x.IsSameMeshAndMaterials(um))) uniqueUnityMeshes.Add(um); + } + #region Materials and Textures - Materials = Nodes.SelectMany(x => x.GetSharedMaterials()).Where(x => x != null).Distinct().ToList(); + Materials = uniqueUnityMeshes.SelectMany(x => x.Renderer.sharedMaterials).Where(x => x != null).Distinct().ToList(); TextureManager = new TextureExporter(useAsset); @@ -228,13 +245,6 @@ namespace UniGLTF #endregion #region Meshes - var unityMeshes = MeshWithRenderer.FromNodes(Nodes).Where(x => x.Mesh.vertices.Any()).ToList(); - var uniqueUnityMeshes = new List(); - foreach (var um in unityMeshes) - { - if (!uniqueUnityMeshes.Any(x => x.IsSameMeshAndMaterials(um))) uniqueUnityMeshes.Add(um); - } - MeshBlendShapeIndexMap = new Dictionary>(); foreach (var unityMesh in uniqueUnityMeshes) {