1,先找到Cube上的8个点,把这些点添加到集合里,
2,调整绘制顺序,再给mesh的顶点和绘制进行赋值
代码如下;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreateCube : MonoBehaviour
{
public Mesh mesh;
// Start is called before the first frame update
void Start()
{
Mesh mesh1 = new Mesh();
Vector3[] vlist = new Vector3[20];
int[] tlist = new int[20];
vlist = mesh.vertices;
tlist = mesh.triangles;
mesh1.vertices = vlist;
mesh1.triangles = tlist;
GetComponent<MeshFilter>().mesh = mesh1;
}
// Update is called once per frame
void Update()
{
}
}