Find normals and triangles

I am trying to get all the triangles of a mesh, I know you have:

transform.GetComponent().mesh.triangles

But its a list of ints…? Shouldn’t it be a list of vector3s??? And how can I get the corresponding normal?

mesh.triangles indeed returns a list of ints rather than vectors. If you want to extract the verts that make up that tri, group those triangle ints into groups of 3, each one an index value into mesh.verticies.

int[] tris = mesh.triangles;
Vector3[] verts = mesh.verticies;

for (int i = 0; i < tris.Length; i+=3)
{
    Vector3 a = verts[tris[i+0]];
    Vector3 b = verts[tris[i+1]];
    Vector3 x = verts[tris[i+2]];

    // You've now got the three vectors that make triangle abc, store them somewhere, do whatever with it, and then the loop counter increments by 3, moving on to the next set of 3 index values (the next triangle!)
}

In this way, vertices can be shared by different triangles, and in most meshes with smooth normals, this is probably the case.

Normals don’t belong to triangles - they belong to vertices. A procedural mesh that is normal mapped should have a mesh.normals array that is the same length as mesh.vertices, with a 1-1 correlation between them.

Each side of a cube is made up of two triangles, which have three vertices each, although two are shared. So a simple cube has 24 vertices and 12 triangles.