setting vertex color of mesh not working

I’m trying to set the vertex color of a mesh. Unity - Scripting API: Mesh.colors

I have the following script attached to two objects in the scene. One of them is a custom mesh exported as FBX from 3DSMax and the other is a Unity Cube object.

	void Update () 
		Mesh mesh = GetComponent<MeshFilter>().mesh;
		Vector3[] vertices = mesh.vertices;
		Color[] colors = new Color[vertices.Length];
		for (int i = 0; i < vertices.Length; i++)
			colors *=;*
  •  }*
  •  mesh.colors = colors;*
  • }*
    What am I missing here? Why isn’t the mesh changing color? Oh and I know that I could just change the material color I’m trying a more advanced effect I just paired down the code for this example.
    Thanks guys

What you have should work. Are you sure your shader supports vertex color? What you are doing here is essentially what I did in the ChangeColor() method in this post, and it worked fine. There is a very simple vertex shader in this post as well.

Hi I wonder if someone knows how to assign the new colors to the mesh as a slow transition over time, when using mesh.colors = colors the modification happens instantly but I am looking for if to happen as a slow transition. I’ve been trying using:

mesh.colors = Color.Lerp (colorsA, colorsB, t); or

But since colorsA and colorsB are arrays containing the different colors for each one of the mesh vertices I haven’t managed to make Lerp work.