using UnityEngine; using UnityEngine.UI; namespace Olympus { // Geometry only: clips existing illustrations without creating replacement question art. [RequireComponent(typeof(CanvasRenderer))] public sealed class RoundedUiMask : MaskableGraphic { public float radius=28; protected override void OnPopulateMesh(VertexHelper vh) { vh.Clear();var r=GetPixelAdjustedRect();float rad=Mathf.Min(radius,Mathf.Min(r.width,r.height)/2); vh.AddVert(r.center,color,new Vector2(.5f,.5f)); for(int corner=0;corner<4;corner++) { Vector2 c=new Vector2(corner==0||corner==3?r.xMax-rad:r.xMin+rad,corner<2?r.yMax-rad:r.yMin+rad); for(int j=0;j<=12;j++) { float a=(corner*90+j*90f/12)*Mathf.Deg2Rad; Vector2 p=c+new Vector2(Mathf.Cos(a),Mathf.Sin(a))*rad; vh.AddVert(p,color,new Vector2((p.x-r.xMin)/r.width,(p.y-r.yMin)/r.height)); } } for(int i=0;i<52;i++)vh.AddTriangle(0,i+1,(i+1)%52+1); } } }