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); } } } } }
public Texture getRenderTexture(SpriteGraphic graphic) { if (graphic != null && GraphicTasks != null) { CanvasGraphicGroup group = FindGraphicGroup(graphic); if (group != null) { UnitMeshInfo info = group.mesh; if (info != null) { return(info.getTexture()); } } } return(null); }
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); } } } }