- Home /
Question by
Irody · Feb 06, 2015 at 04:08 PM ·
vertexcolor
How do I change the vertex Colors of my model to white in C#?
Hi Forum, I want my player to turn white for a short time when hit. Thanks in advance.
Comment
Default vertex colours are already white. You'll need to look at modifying the material, texture and/or shader.
The model does have vertex colors applied already and I want to change them to white or another color. The model should turn white and after .5 seconds it should go back to the original vertex colors.
Answer by VesuvianPrime · Feb 06, 2015 at 04:24 PM
Color32[] colors = mesh.colors32;
System.Array.Resize(ref colors, mesh.vertexCount);
for (int index=0; index < colors.Length; index++)
colors[index] = Color.white;
mesh.colors32 = colors;
Thank you this is working great. But how do i change the color back to its original vertex color?
Store the old colours in an array somewhere.
private Color32[] m_OldColors;
// Set to white
m_OldColors = mesh.colors32;
Color32[] colors = mesh.colors32;
System.Array.Resize(ref colors, mesh.vertexCount);
for (int index=0; index < colors.Length; index++)
colors[index] = Color.white;
mesh.colors32 = colors;
// Set back to original colors
mesh.colors32 = m_OldColors;
Your answer