- Home /
Batching between copied meshes
Hi, I'm trying to setup batching between different copies of a single mesh. I can't use the original sharedMesh because I need to change its UVs per object (Unity breaks batching if I change the original Material, so I am changing the UVs instead).
This is how I copy the mesh:
Mesh newMesh = (Mesh)Object.Instantiate(skinnedMesh.sharedMesh);
skinnedMesh.sharedMesh = newMesh;
Then I change the UVs like this:
for(int i = 0; i < originalUVs.Count; i++)
snapUVs[i] = this.m_originalUVs[i] + offset;
skinnedMesh.sharedMesh.uv = snapUVs.ToArray();
This all works fine as far as display, but automatic batching won't work! Every object gets its own render call. I checked that the material was NOT cloned, so that's fine. The Unity docs don't say anything about the mesh having to be the same... So I'm not really sure where to continue from here.
Please help :(
Answer by andyman404 · Oct 04, 2015 at 04:32 AM
This answer is probably a few years too late, but it might help someone else.
Currently, only Mesh Renderers and Particle Systems are batched. This means that skinned meshes, cloth, trail renderers and other types of rendering components are not batched. From your variable name, "skinnedMesh", it looks like you are using a skinned mesh renderer.
For more info, please see http://docs.unity3d.com/Manual/DrawCallBatching.html. There is a section on the bottom of the page that describes this.