- Home /
mesh.colors doesnt seem to work at the moment
I have used this same code in another script and it works, but this is not working for some reason.
Here is the script:
IEnumerator FlashYellow() {
print ("Here We are");
print ( touchedObj.name );
var objMF = touchedObj.GetComponent<MeshFilter>();
var colors = new Color[ objMF.mesh.vertexCount ];
while( isFlashing )
{
print ("okok");
for(var i = 0; i < colors.Length; i++)
{
print ("YO" );
colors[i] = new Color(234/255.0f, 83/255.0f, 57/255.0f, 0);
}
objMF.mesh.colors = colors;
yield return new WaitForEndOfFrame();
}
}
All of the prints are showing up the in the console... I'm sure I'm goofing something up, but like I said, I have used this code with another script and it works fine, it just wasn't an IEnumerator in the other script. I have changed the colour multiple times and I have used it on a prefab and just a regular cube and neither works. The code should simply change the vertex colours and it doesn't. At the moment it is locked in the while loop, but that shouldn't affect wether the colour shows either..
I'm lost, any help would be appreciated.
I threw in:
print (obj$$anonymous$$F.mesh.colors[1]);
And it shows the correct colour output, but why doesn't the object change colour??
Oh, it might be that the shader I'm using doesn't support vertex colours.. $$anonymous$$aybe I just solved this
I stil believe your shader is the problem. Try it with one that definitely supports vertex colors.
Answer by dudester · Oct 14, 2015 at 10:54 PM
In shader use o.albedo = IN.colors and under input put color : Colors ; that will make it use mesh colors as a texture for the mesh.
Ya, I'm shader traded alright. I made a shader a long time ago for this, but I forgot all about it. Thanks dudester and cherno..