通过mesh生成一个方块
- 声明mesh类
Mesh mesh = new Mesh();
-
获取方块的顶点
List<Vector3> vertices = new List<Vector3>() { new Vector3(0,0,0), new Vector3(0,5,0), new Vector3(5,5,0), new Vector3(5,0,0), new Vector3(0,0,5), new Vector3(0,5,5), new Vector3(5,5,5), new Vector3(5,0,5), new Vector3(0,0,0), new Vector3(0,5,0), new Vector3(5,5,0), new Vector3(5,0,0), new Vector3(0,0,5), new Vector3(0,5,5), new Vector3(5,5,5), new Vector3(5,0,5), };
3.根据下标 添加三角形
List<int> triangle = new List<int>()
{
0,2,1,0,3,2,//前
4,5,6,7,4,6,//后
4,1,5,0,1,4,//左
2,3,6,3,7,6,//右
5,1,6,1,2,6,//上
4,3,0,4,7,3//下
};
4.重新生成发现,设置顶点和三角