After changing vertices in Text Mesh I?m not able to set a new Color to it.
Am I missing something ?
Example:
GameObject item = Instantiate(prefab, transform.position, transform.rotation) as GameObject;
var textMesh = item.GetComponent<tk2dTextMesh>();
string text = "Hello 2D Toolkit";
textMesh.maxChars=text.Length;
textMesh.text = text;
Color c = textMesh.color;
c = Color.red;
textMesh.color = c;
textMesh.Commit();
MeshFilter mf = textMesh.GetComponent<MeshFilter>();
int n;
Vector3[] vertices = mf.mesh.vertices;
for(int k=0; k<text.Length; k++)
{
n = Random.Range(-3,3);
for(int j=0; j < 4; j++)
{
vertices[k*4 + j].z += n;
}
}
mf.mesh.vertices = vertices;
mf.mesh.RecalculateBounds();
Color c1 = textMesh.color;
c1 = Color.blue;
textMesh.color = c1;
textMesh.Commit();