DrawStruct.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. using UnityEngine.UI;
  4. namespace WXB
  5. {
  6. public class DrawStruct
  7. {
  8. }
  9. public class DrawLineStruct : DrawStruct
  10. {
  11. public struct Line
  12. {
  13. public Vector2 leftPos;
  14. public float width;
  15. public float height;
  16. public Vector2 uv;
  17. public Color color;
  18. public int dynSpeed;
  19. public TextNode node;
  20. public void Render(VertexHelper vh, ref float curwidth)
  21. {
  22. int start = vh.currentIndexCount;
  23. Color c = color;
  24. if (c.a <= 0.01f)
  25. return;
  26. if (curwidth >= width)
  27. {
  28. // 完整显示
  29. Tools.AddLine(vh, leftPos, uv, width, height, c);
  30. }
  31. else
  32. {
  33. Tools.AddLine(vh, leftPos, uv, curwidth, height, c);
  34. }
  35. switch (node.effectType)
  36. {
  37. case EffectType.Outline:
  38. c = node.effectColor;
  39. Effect.Outline(vh, start, c, node.effectDistance);
  40. break;
  41. case EffectType.Shadow:
  42. c = node.effectColor;
  43. Effect.Shadow(vh, start, c, node.effectDistance);
  44. break;
  45. }
  46. curwidth -= width;
  47. }
  48. }
  49. public List<Line> lines = new List<Line>();
  50. public void Render(float width, VertexHelper vh)
  51. {
  52. for (int i = 0; i < lines.Count; ++i)
  53. {
  54. lines[i].Render(vh, ref width);
  55. if (width <= 0f)
  56. break;
  57. }
  58. }
  59. }
  60. }