From c90da0da7970c2c34b04eccb2b83dfeac56876bc Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 11 Oct 2021 15:11:38 +0900 Subject: [PATCH 1/2] Mesh.vertexCount before assignment --- Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs index 154ed16f4..f4e9f10c4 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs @@ -201,7 +201,7 @@ namespace UniGLTF else if (renderer is MeshRenderer mr) { var filter = mr.GetComponent(); - if (filter.hideFlags == HideFlags.None && Mesh.vertexCount > 0 && filter != null) + if (filter != null && filter.hideFlags == HideFlags.None && filter.sharedMesh.vertexCount > 0) { Mesh = filter.sharedMesh; } From c28b51ae1f4d7adf8f88d0375be05a567ff49426 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 11 Oct 2021 15:22:03 +0900 Subject: [PATCH 2/2] null test filter.sharedMesh --- Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs index f4e9f10c4..37c4e5094 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExportInfo.cs @@ -201,9 +201,12 @@ namespace UniGLTF else if (renderer is MeshRenderer mr) { var filter = mr.GetComponent(); - if (filter != null && filter.hideFlags == HideFlags.None && filter.sharedMesh.vertexCount > 0) + if (filter != null && filter.hideFlags == HideFlags.None) { - Mesh = filter.sharedMesh; + if (filter.sharedMesh != null && filter.sharedMesh.vertexCount > 0) + { + Mesh = filter.sharedMesh; + } } } else