Hello everyone, i have to recolor some meshes on my scene, and since shader i use can work with vertex color, so i decided to try just change colors of vertexes runtime. But then i faced with increasing batches. Recolored mesh doesn’t batch with others, despite they share one material.
I decided to check it again and create empty project with two standart unity’s quads. Material use shader (Particles/AlphaBlended) and “Default particle” as Texture. Then i attached to one of quads script, that change its colors.
void Start () {
mesh = this.GetComponent<MeshFilter>().mesh;
Color[] colors = new Color[mesh.vertexCount];
for (int i = 0; i < colors.Length; i++)
colors *= Color.black;*
mesh.colors = colors;
- }*
But after all i get 2 batches, instead of 1. Enable script = 2 batches, disable script = 1batch. Same material, only 4 verts in each object. What have i missed? Where is my mistake? Shouldn’t it be batched?
UPDATE
I managed to get quads batched. First of all i changed in script mesh property, to sharedMesh, which is according to Unitydocs actuall asset in library. After that, as expected, all my quads became black. Then i changed script again and put mesh thing back. And here we are, 1 batch for at least 6 squads colored with different colors.
Anybody have a suggestions why is it works like that? I suspect, that i forget to turn off some checkbox somewhere, or read some manual article. Looks like, that changing shared mesh colors change something else as well. Any help?