标题: 网格合并代码 [打印本页] 作者: 奔跑的小兔 时间: 2012-3-16 12:19 标题: 网格合并代码 I recently hit a problem where I needed to combine meshes into a single renderer, but the meshes were using different materials. The built-in MeshCombineUtility doesn't support multiple submeshes. So, I rewrote it.
It's also now set up as an accumulating object, so you can create a MeshCombineUtility and add instances to it one by one, instead of needing to collect them all up in a list and passing them in in one go. Though it's a little more efficient if you can do that.
It uses LINQ, so I guess it doesn't work on iOS - but this is the kind of thing that you should probably be doing in the editor or in AssetPostProcessors anyway.
MeshCombineUtility.cs
To go with this, I also amended Neodrop's Combine Children Extended to combine everything into a single mesh with multiple materials:
CombineChildren.cs
Hope you find it useful. Let me know if you come up with any improvements or can point out any bugs. I think that the triangle strip handling is a little more fragile than the original - if you tell it you're using strips, and then you give it something that doesn't have strips, then it'll crash, while UT's original version would just