Skip to content

Commit d1c078d

Browse files
committed
Add option to merge submeshes in CombineChildrenMeshes
1 parent 0aab015 commit d1c078d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Runtime/CombineChildrenMeshes.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Zigurous.Graphics
66
/// Combines the meshes of the children of the game object into one mesh.
77
/// </summary>
88
[RequireComponent(typeof(MeshFilter))]
9+
[RequireComponent(typeof(MeshRenderer))]
910
[AddComponentMenu("Zigurous/Graphics/Combine Children Meshes")]
1011
public sealed class CombineChildrenMeshes : MonoBehaviour
1112
{
@@ -21,6 +22,12 @@ public sealed class CombineChildrenMeshes : MonoBehaviour
2122
[Tooltip("Removes the child meshes from the game object after combining.")]
2223
public bool removeChildMeshes = true;
2324

25+
/// <summary>
26+
/// Combines all of the meshes into a single submesh.
27+
/// </summary>
28+
[Tooltip("Combines all of the meshes into a single submesh.")]
29+
public bool mergeSubmeshes = true;
30+
2431
/// <summary>
2532
/// Optimizes the combined mesh data to improve rendering performance.
2633
/// </summary>
@@ -79,7 +86,7 @@ public Mesh Combine()
7986
// Create a new mesh from all of the combined children
8087
Mesh combinedMesh = new Mesh();
8188
combinedMesh.name = "Combined Mesh";
82-
combinedMesh.CombineMeshes(combine);
89+
combinedMesh.CombineMeshes(combine, mergeSubmeshes);
8390

8491
if (optimizeMesh) {
8592
combinedMesh.Optimize();

0 commit comments

Comments
 (0)