I am trying to per-vertex color a piece of cloth. I am using unity’s particle/alpha blended shader but then the cloth gets transparent. I am not sure what I am doing wrong. Changing the shaders also don’t solve the problem. I am using Obicloth.
void Awake()
{
Mesh mesh = gameObject.GetComponent<MeshFilter>().sharedMesh;
Vector3[] vertices = mesh.vertices;
int[] triangles = mesh.triangles;
ObiCloth cloth = gameObject.GetComponent<ObiCloth>();
Vector3[] verticesModified = new Vector3[triangles.Length];
int[] trianglesModified = new int[triangles.Length];
Color[] colors = new Color[triangles.Length];
Color c = new Color();
for(int i = 0; i < triangles.Length; i++)
{
verticesModified _= vertices[triangles*];*_
trianglesModified = i;
int index = triangles*;*
if(i%3 == 0)
{
c = new Color(Random.Range(0.0f, 1.0f),
Random.Range(0.0f, 1.0f),
Random.Range(0.0f, 1.0f),
1.0f);
colors[index] = c;
}
}
mesh.vertices = verticesModified;
mesh.triangles = triangles;
mesh.colors = colors;
mesh.RecalculateNormals();
}