private List <UIVertex> DrawPie() { if (IsShowPercnet) { _pieText = new List <PieText>(); } List <UIVertex> vertexs = new List <UIVertex>(); float perRadian = Mathf.PI * 2 / Smooth; float totalRadian = 0; float boomRadian = BoomDegree / 180 * Mathf.PI; float pieRadianBase = Mathf.PI * 2 - boomRadian * PieData.PieDatas.Count; for (int i = 0; i < PieData.PieDatas.Count; i++) { PieData data = PieData.PieDatas[i]; float endRadian = boomRadian + data.Percent * pieRadianBase + totalRadian; for (float r = boomRadian + totalRadian; r < endRadian; r += perRadian) { Vector2 first = new Vector2(Mathf.Cos(r), Mathf.Sin(r)) * HollowWidth; Vector2 second = new Vector2(Mathf.Cos(r + perRadian), Mathf.Sin(r + perRadian)) * HollowWidth; Vector2 third = new Vector2(Mathf.Cos(r), Mathf.Sin(r)) * PieRadius; Vector2 four = new Vector2(Mathf.Cos(r + perRadian), Mathf.Sin(r + perRadian)) * PieRadius; vertexs.Add(GetUIVertex(first, data.Color)); vertexs.Add(GetUIVertex(third, data.Color)); vertexs.Add(GetUIVertex(second, data.Color)); vertexs.Add(GetUIVertex(second, data.Color)); vertexs.Add(GetUIVertex(third, data.Color)); vertexs.Add(GetUIVertex(four, data.Color)); } if (IsShowPercnet) { float middleRadian = boomRadian + data.Percent * pieRadianBase / 2 + totalRadian; float brokenLineLength = PieRadius * 0.2f; Vector2 middlePoint = new Vector2(Mathf.Cos(middleRadian), Mathf.Sin(middleRadian)) * PieRadius; Vector2 secondPoint = middlePoint + new Vector2(Mathf.Cos(middleRadian), Mathf.Sin(middleRadian)) * brokenLineLength; Vector2 first = middlePoint + new Vector2(Mathf.Sin(middleRadian), -Mathf.Cos(middleRadian)) * BrokenLineWidth / 2; Vector2 second = middlePoint + new Vector2(-Mathf.Sin(middleRadian), Mathf.Cos(middleRadian)) * BrokenLineWidth / 2; Vector2 third = secondPoint + new Vector2(Mathf.Sin(middleRadian), -Mathf.Cos(middleRadian)) * BrokenLineWidth / 2; Vector2 four = secondPoint + new Vector2(-Mathf.Sin(middleRadian), Mathf.Cos(middleRadian)) * BrokenLineWidth / 2; Vector2 five; Vector2 six; Vector2 seven; Vector2 eight; vertexs.Add(GetUIVertex(first, data.Color)); vertexs.Add(GetUIVertex(second, data.Color)); vertexs.Add(GetUIVertex(third, data.Color)); vertexs.Add(GetUIVertex(third, data.Color)); vertexs.Add(GetUIVertex(second, data.Color)); vertexs.Add(GetUIVertex(four, data.Color)); five = secondPoint + new Vector2(0, BrokenLineWidth / 2.0f); six = secondPoint + new Vector2(0, -BrokenLineWidth / 2.0f); if (middleRadian > Mathf.PI / 2 && middleRadian < Mathf.PI * 3 / 2) { seven = five + new Vector2(-brokenLineLength, 0); eight = six + new Vector2(-brokenLineLength, 0); //绘制右边的文字 _pieText.Add(new PieText(data.Percent * 100 + "%" + labelName[i], eight, false)); } else { seven = five + new Vector2(brokenLineLength, 0); eight = six + new Vector2(brokenLineLength, 0); //绘制左边的文字 _pieText.Add(new PieText(data.Percent * 100 + "%" + labelName[i], eight, true)); } vertexs.Add(GetUIVertex(third, data.Color)); vertexs.Add(GetUIVertex(four, data.Color)); vertexs.Add(GetUIVertex(five, data.Color)); vertexs.Add(GetUIVertex(five, data.Color)); vertexs.Add(GetUIVertex(six, data.Color)); vertexs.Add(GetUIVertex(third, data.Color)); vertexs.Add(GetUIVertex(five, data.Color)); vertexs.Add(GetUIVertex(six, data.Color)); vertexs.Add(GetUIVertex(seven, data.Color)); vertexs.Add(GetUIVertex(seven, data.Color)); vertexs.Add(GetUIVertex(eight, data.Color)); vertexs.Add(GetUIVertex(six, data.Color)); } totalRadian = endRadian; } if (IsShowThumbnail) { vertexs.AddRange(DrawThumbnail()); } return(vertexs); }