Change Single GameObject Color

As a way of trying to change a GameObject’s mesh color without adding draw calls, I tried doing this.

SkinnedMeshRenderer skinnedRenderer = gameObject.GetComponentInChildren(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
Color deadColor = new Color(0f, 0f, 0f, 1f);
Mesh objectMesh = skinnedRenderer.sharedMesh;
				
for(int i = 0; i < objectMesh.colors.Length; i++)
{
	Color vertexColor = objectMesh.colors[i];
	vertexColor = deadColor;
}

Shouldn’t this change all of these GameObjects black? It seems to have no effect. What could I be doing wrong?

You have to send all arrays dealing with vertices all at once, as an array. You can’t loop through it and make changes directly (or even modify any single vertex attribute directly). And even if you could do that, your code wouldn’t do that.

Like this.

Ah yes, you’re absolutely right. I guess this doesn’t change a single GameObject color after all since all instances ended up changing to the same color when I applied this code to one instance.