How to get all pixels used by the mesh UVs?

Hello,

I’m trying to get the number of red pixels in a mesh texture. I can get all the pixels using Texture2D.GetPixels(), but how can I get only the pixels covered by the mesh uv map?

Getting pixels at the vertex UVs won’t be enough, I guess you want to see all the red pixels inside the triangles as well?
In that case, you’d need to go triangle by triangle; get the triangles from the mesh (the indices). Iterate over triangles and always get it’s vertices’ UVs. Project those UVs on the texture, use a 2D algorithm to ‘draw’ the triangle on the texture, but instead of drawing, just count the red pixels. Repeat for every triangle in the mesh, sum up the pixels.