VertexHelper
protected override void OnPopulateMesh(VertexHelper vh)
{
    base.OnPopulateMesh(vh);
    Debug.LogError(vh.currentIndexCount);//6个 三角形的索引
    Debug.LogError(vh.currentVertCount);//4个 顶点个数,图片的四个角
    List<UIVertex> list = new List<UIVertex>();
    vh.GetUIVertexStream(list);
    Debug.LogError(list.Count);//6个
    for (int i = 0; i < list.Count; i++)
    {
        //会有两个是重复的
        Debug.LogError(list[i].position);
    }
    vh.AddVert(list[2]);//添加顶点
    vh.AddTriangle(0, 4, 3);//添加三角形
    Debug.LogError(vh.currentIndexCount);//9个
    Debug.LogError(vh.currentVertCount);//5个
    vh.GetUIVertexStream(list);
    Debug.LogError(list.Count);//9个
}


一个工具类VertexHelper,帮助UI生成网格


首页 我的博客
粤ICP备17103704号