直接上代码
Vector3[] vertices = new Vector3[sprite.vertices.Length];
for(int j = 0; j < vertices.Length; j++)
{
vertices[j] = new Vector3(sprite.vertices[j].x, sprite.vertices[j].y, 0);
}
int[] triangles = new int[sprite.triangles.Length];
for (int j = 0; j < triangles.Length; j++)
{
triangles[j] = sprite.triangles[j];
}
Mesh mesh = new Mesh();
mesh.SetVertices(vertices);
mesh.SetTriangles(triangles,0);
mesh.SetUVs(0, sprite.uv);