- Home /
Answer by N1nja · Jul 11, 2010 at 04:18 AM
You could iterate through the Mesh of the model.. which is stored inside of GameObject->MeshFilter(component)->shareMesh(or mesh).. the Mesh object contains Triangle Indicies, Vertices, Vertex Colors, Normals, Texture Coordinates, etc..
You can definitely change the Color of the Triangle you want to highlight through this Mesh structure contained in the GameObject..
C# Example(not tested, written from mind.. lol)
class TriangleHighlighter : MonoBehaviour
{
void Start()
{
MeshFilter meshFilter = gameObject.GetComponent<MeshFilter>();
Mesh mesh = meshFilter.sharedMesh;
Color[] vertexColors = mesh.colors;
for(int i = 0; i < (int)(vertexColors.Length / 2); ++i)
{
vertexColors[i] = Color.blue;
}
mesh.colors = vertexColors; // update the vertex colors
}
}
It gives me IndexOutOfRangeException: Array index is out of range error
sorry.. replace the "3" with (int)(vertexColors.Length / 2)
Your answer
Follow this Question
Related Questions
Which Software/Tool is used for creating Game Objects? 0 Answers
Problem with importing Collada files 1 Answer
Imported Blender Models Issue 1 Answer
Rotate 180 degrees over x axis over time 1 Answer
How to make a 3D Hex Model with Unity? 3 Answers