diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshWithRenderer.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshWithRenderer.cs index 22e2f4d36..0f39371de 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshWithRenderer.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshWithRenderer.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using UnityEngine; namespace UniGLTF @@ -15,5 +16,24 @@ namespace UniGLTF Mesh = x.GetSharedMesh(); Renderer = x.GetComponent(); } + + public static IEnumerable FromNodes(IEnumerable nodes) + { + foreach (var node in nodes) + { + var x = new MeshWithRenderer(node); + if (x.Mesh == null) + { + continue; ; + } + if (x.Renderer.sharedMaterials == null + || x.Renderer.sharedMaterials.Length == 0) + { + continue; + } + + yield return x; + } + } } } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs index 55e8fee4a..807065e6f 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs @@ -252,23 +252,7 @@ namespace UniGLTF #endregion #region Meshes - var unityMeshes = Nodes - .Select(x => new MeshWithRenderer(x)) - .Where(x => - { - if (x.Mesh == null) - { - return false; - } - if (x.Renderer.sharedMaterials == null - || x.Renderer.sharedMaterials.Length == 0) - { - return false; - } - - return true; - }) - .ToList(); + var unityMeshes = MeshWithRenderer.FromNodes(Nodes).ToList(); MeshBlendShapeIndexMap = new Dictionary>(); foreach (var (mesh, gltfMesh, blendShapeIndexMap) in MeshExporter.ExportMeshes(