using UnityEngine; using UnityEngine.UI; namespace TowerDevil { [RequireComponent(typeof(CanvasRenderer))] public sealed class SealIcon : MaskableGraphic { public Color top, bottom; protected override void OnPopulateMesh(VertexHelper mesh) { mesh.Clear(); Rect r = rectTransform.rect; void Vertex(float x, float y) => mesh.AddVert( new Vector3(r.xMin + x * r.width, r.yMin + y * r.height), Color.Lerp(bottom, top, y), Vector2.zero); Vertex(.5f, 1); Vertex(1, .83f); Vertex(1, .42f); Vertex(.5f, 0); Vertex(0, .42f); Vertex(0, .83f); for (int i = 1; i < 5; i++) mesh.AddTriangle(0, i, i + 1); } } }