diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/Import/AnimationImporterUtil.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/Import/AnimationImporterUtil.cs index fa927d235..f33a35d97 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/Import/AnimationImporterUtil.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/Import/AnimationImporterUtil.cs @@ -310,9 +310,6 @@ namespace UniGLTF { var node = data.GLTF.nodes[channel.target.node]; var mesh = data.GLTF.meshes[node.mesh]; - var primitive = mesh.primitives.FirstOrDefault(); - var targets = primitive.targets; - if (!gltf_mesh_extras_targetNames.TryGet(mesh, out List targetNames)) { throw new UniGLTFNotSupportedException("glTF BlendShape Animation. targetNames invalid."); diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs index ad1925f11..1adba2baa 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs @@ -78,6 +78,10 @@ namespace UniGLTF { return false; } + if (Mesh.triangles.Length == 0) + { + return false; + } if (Materials == null) { return false; diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs index bd31cec00..e2d09bb06 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs @@ -273,6 +273,12 @@ namespace UniGLTF ? MeshExporter_DividedVertexBuffer.Export(_data, unityMesh, Materials, m_settings.InverseAxis.Create(), m_settings) : MeshExporter_SharedVertexBuffer.Export(_data, unityMesh, Materials, m_settings.InverseAxis.Create(), m_settings) ; + + if (gltfMesh.primitives == null || gltfMesh.primitives.Count == 0) + { + Debug.LogError($"gltfMesh.primitives is empty: {unityMesh.Mesh.name}"); + } + _gltf.meshes.Add(gltfMesh); Meshes.Add(unityMesh.Mesh); if (!MeshBlendShapeIndexMap.ContainsKey(unityMesh.Mesh))