public void DrawGizmos(Graphic graphic) { CanvasGraphicGroup group = FindGraphicGroup(graphic); if (group != null) { UnitMeshInfo rendermesh = group.mesh; if (rendermesh != null && rendermesh.getTexture() != null) { Gizmos.color = Color.red; int vertcnt = rendermesh.VertCnt(); int uvcnt = rendermesh.UVCnt(); if (vertcnt != uvcnt) { Debug.LogError("data error"); } else { for (int i = 0; i < vertcnt; i += 4) { Vector3 p1 = getPoint(graphic, rendermesh.GetVert(i)); Vector3 p2 = getPoint(graphic, rendermesh.GetVert(i + 1)); Vector3 p3 = getPoint(graphic, rendermesh.GetVert(i + 2)); Vector3 p4 = getPoint(graphic, rendermesh.GetVert(i + 3)); Gizmos.DrawLine(p1, p2); Gizmos.DrawLine(p2, p3); Gizmos.DrawLine(p3, p4); Gizmos.DrawLine(p4, p1); } } } } }
void RefreshSubUIMesh(InlineText text, CanvasGraphicGroup group, SpriteAsset matchAsset, Vector3[] Pos, Vector2[] UV, List <string> joblist) { // set mesh tempMesh.SetAtlas(matchAsset); tempMesh.SetUVLen(UV.Length); tempMesh.SetVertLen(Pos.Length); SpriteGraphic graphic = group.graphic; //think about culling and screen coordinate....... for (int i = 0; i < Pos.Length; ++i) { //text object pos Vector3 value = Pos[i]; Vector3 worldpos = text.transform.TransformPoint(value); Vector3 localpos = group.graphic.transform.InverseTransformPoint(worldpos); tempMesh.SetVert(i, localpos); } for (int i = 0; i < UV.Length; ++i) { Vector2 value = UV[i]; tempMesh.SetUV(i, value); } //rendermesh UnitMeshInfo currentMesh = group.mesh; if (!currentMesh.Equals(tempMesh)) { if (joblist != null && joblist.Count > 0) { currentMesh.AddCopy(tempMesh); tempMesh.Clear(); } else { currentMesh.Copy(tempMesh); } } if (currentMesh.VertCnt() > 3 && currentMesh.UVCnt() > 3) { graphic.Draw(this); } else { graphic.Draw(null); } group.isDirty = true; }
public void FillMesh(Graphic graphic, VertexHelper vh) { CanvasGraphicGroup group = FindGraphicGroup(graphic); if (group != null) { UnitMeshInfo rendermesh = group.mesh; if (rendermesh != null && rendermesh.getTexture() != null) { int vertcnt = rendermesh.VertCnt(); int uvcnt = rendermesh.UVCnt(); if (vertcnt != uvcnt) { Debug.LogError("data error"); } else { for (int i = 0; i < vertcnt; ++i) { vh.AddVert(rendermesh.GetVert(i), graphic.color, rendermesh.GetUV(i)); } int cnt = vertcnt / 4; for (int i = 0; i < cnt; ++i) { int m = i * 4; vh.AddTriangle(m, m + 1, m + 2); vh.AddTriangle(m + 2, m + 3, m); } //vh.AddTriangle(0, 1, 2); //vh.AddTriangle(2, 3, 0); } } } }