MeshFilter mesh_filter = gameObject.AddComponent<MeshFilter>();
MeshRenderer mesh_renderer = gameObject.AddComponent<MeshRenderer>();
// gameObject.GetComponent<MeshRenderer>().material
Mesh mesh = mesh_filter.mesh;
mesh.Clear();
//设置顶点
mesh.vertices = new Vector3[] { new Vector3(0, 0, 0), new Vector3(0, 1, 0), new Vector3(1, 1, 0),new Vector3(1, 0, 0) };
//设置三角形顶点顺序,顺时针设置
mesh.triangles = new int[] {
0,1,2,
2,3,0
};
网友评论