TempleSymbol.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace Olympus
  4. {
  5. // Small editable geometric accents; no notification state is baked into background art.
  6. [RequireComponent(typeof(CanvasRenderer))]
  7. public sealed class TempleSymbol : MaskableGraphic
  8. {
  9. public enum Shape { Calendar, Notification, IdentityHalo }
  10. public Shape shape;
  11. static readonly Color Gold=new Color32(239,194,103,255), Ink=new Color32(54,31,16,255);
  12. protected override void OnPopulateMesh(VertexHelper vh)
  13. {
  14. vh.Clear();
  15. if(shape==Shape.Notification){Disc(vh,.5f,.5f,.5f,Gold);Disc(vh,.5f,.5f,.39f,new Color32(208,43,32,255));Disc(vh,.39f,.65f,.09f,new Color32(255,174,132,255));}
  16. else if(shape==Shape.IdentityHalo){Disc(vh,.5f,.5f,.5f,new Color32(61,200,186,150));Disc(vh,.5f,.5f,.46f,Gold);Disc(vh,.5f,.5f,.42f,Ink);}
  17. else
  18. {
  19. Quad(vh,.09f,.13f,.91f,.84f,Ink);Quad(vh,.13f,.17f,.87f,.8f,Gold);Quad(vh,.18f,.22f,.82f,.62f,Ink);
  20. Quad(vh,.29f,.73f,.36f,.94f,Gold);Quad(vh,.64f,.73f,.71f,.94f,Gold);
  21. for(int x=0;x<3;x++)for(int y=0;y<2;y++)Quad(vh,.26f+x*.19f,.3f+y*.18f,.36f+x*.19f,.4f+y*.18f,Gold);
  22. }
  23. }
  24. Vector2 P(float x,float y){var r=rectTransform.rect;return new Vector2(r.x+x*r.width,r.y+y*r.height);}
  25. void Quad(VertexHelper v,float x,float y,float xx,float yy,Color c)
  26. {
  27. int i=v.currentVertCount;v.AddVert(P(x,y),c,Vector2.zero);v.AddVert(P(x,yy),c,Vector2.zero);v.AddVert(P(xx,yy),c,Vector2.zero);v.AddVert(P(xx,y),c,Vector2.zero);v.AddTriangle(i,i+1,i+2);v.AddTriangle(i,i+2,i+3);
  28. }
  29. void Disc(VertexHelper v,float x,float y,float radius,Color c)
  30. {
  31. int n=v.currentVertCount;v.AddVert(P(x,y),c,Vector2.zero);
  32. for(int i=0;i<=64;i++){float a=i*Mathf.PI/32;v.AddVert(P(x+Mathf.Cos(a)*radius,y+Mathf.Sin(a)*radius),c,Vector2.zero);if(i>0)v.AddTriangle(n,n+i,n+i+1);}
  33. }
  34. }
  35. }