RenderCache_CartoonData.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. namespace WXB
  7. {
  8. // 缓存渲染元素
  9. public partial class RenderCache
  10. {
  11. class CartoonData : BaseData
  12. {
  13. public Cartoon cartoon;
  14. public void Reset(NodeBase n, Cartoon c, Rect r, Line l)
  15. {
  16. node = n;
  17. cartoon = c;
  18. rect = r;
  19. line = l;
  20. }
  21. protected override void OnRelease()
  22. {
  23. cartoon = null;
  24. }
  25. public override void Render(VertexHelper vh, Rect area, Vector2 offset, float pixelsPerUnit)
  26. {
  27. Color currentColor = node.d_color;
  28. if (currentColor.a <= 0.01f)
  29. return;
  30. Vector2 leftPos = GetStartLeftBottom(1f) + offset;
  31. Tools.LB2LT(ref leftPos, area.height);
  32. CartoonDraw cd = node.owner.GetDraw(DrawType.Cartoon, node.keyPrefix + cartoon.GetHashCode(),
  33. (Draw d, object p)=>
  34. {
  35. CartoonDraw cad = d as CartoonDraw;
  36. cad.cartoon = cartoon;
  37. cad.isOpenAlpha = node.d_bBlink;
  38. cad.isOpenOffset = false;
  39. }) as CartoonDraw;
  40. cd.Add(leftPos, cartoon.width, cartoon.height, currentColor);
  41. }
  42. }
  43. }
  44. }