Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

LabelLine.cs 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using UnityEngine;
  3. namespace XCharts.Runtime
  4. {
  5. /// <summary>
  6. /// 标签的引导线
  7. /// </summary>
  8. [System.Serializable]
  9. public class LabelLine : ChildComponent, ISerieExtraComponent, ISerieDataComponent
  10. {
  11. /// <summary>
  12. /// 标签视觉引导线类型
  13. /// </summary>
  14. public enum LineType
  15. {
  16. /// <summary>
  17. /// 折线
  18. /// </summary>
  19. BrokenLine,
  20. /// <summary>
  21. /// 曲线
  22. /// </summary>
  23. Curves,
  24. /// <summary>
  25. /// 水平线
  26. /// </summary>
  27. HorizontalLine
  28. }
  29. [SerializeField] private bool m_Show = true;
  30. [SerializeField] private LineType m_LineType = LineType.BrokenLine;
  31. [SerializeField] private Color32 m_LineColor = ChartConst.clearColor32;
  32. [SerializeField] private float m_LineAngle = 0;
  33. [SerializeField] private float m_LineWidth = 1.0f;
  34. [SerializeField] private float m_LineGap = 1.0f;
  35. [SerializeField] private float m_LineLength1 = 25f;
  36. [SerializeField] private float m_LineLength2 = 15f;
  37. [SerializeField] private SymbolStyle m_StartSymbol = new SymbolStyle() { show = false, type = SymbolType.Circle, size = 3 };
  38. [SerializeField] private SymbolStyle m_EndSymbol = new SymbolStyle() { show = false, type = SymbolType.Circle, size = 3 };
  39. public void Reset()
  40. {
  41. m_Show = false;
  42. m_LineType = LineType.BrokenLine;
  43. m_LineColor = Color.clear;
  44. m_LineAngle = 0;
  45. m_LineWidth = 1.0f;
  46. m_LineGap = 1.0f;
  47. m_LineLength1 = 25f;
  48. m_LineLength2 = 15f;
  49. }
  50. /// <summary>
  51. /// Whether the label line is showed.
  52. /// |是否显示视觉引导线。
  53. /// </summary>
  54. public bool show
  55. {
  56. get { return m_Show; }
  57. set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
  58. }
  59. /// <summary>
  60. /// the type of visual guide line.
  61. /// |视觉引导线类型。
  62. /// </summary>
  63. public LineType lineType
  64. {
  65. get { return m_LineType; }
  66. set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
  67. }
  68. /// <summary>
  69. /// the color of visual guild line.
  70. /// |视觉引导线颜色。默认和serie一致取自调色板。
  71. /// </summary>
  72. public Color32 lineColor
  73. {
  74. get { return m_LineColor; }
  75. set { if (PropertyUtil.SetStruct(ref m_LineColor, value)) SetVerticesDirty(); }
  76. }
  77. /// <summary>
  78. /// the angle of visual guild line.
  79. /// |视觉引导线的固定角度。对折线和曲线有效。
  80. /// </summary>
  81. public float lineAngle
  82. {
  83. get { return m_LineAngle; }
  84. set { if (PropertyUtil.SetStruct(ref m_LineAngle, value)) SetVerticesDirty(); }
  85. }
  86. /// <summary>
  87. /// the width of visual guild line.
  88. /// |视觉引导线的宽度。
  89. /// </summary>
  90. public float lineWidth
  91. {
  92. get { return m_LineWidth; }
  93. set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
  94. }
  95. /// <summary>
  96. /// the gap of container and guild line.
  97. /// |视觉引导线和容器的间距。
  98. /// </summary>
  99. public float lineGap
  100. {
  101. get { return m_LineGap; }
  102. set { if (PropertyUtil.SetStruct(ref m_LineGap, value)) SetVerticesDirty(); }
  103. }
  104. /// <summary>
  105. /// The length of the first segment of visual guide line.
  106. /// |视觉引导线第一段的长度。
  107. /// </summary>
  108. public float lineLength1
  109. {
  110. get { return m_LineLength1; }
  111. set { if (PropertyUtil.SetStruct(ref m_LineLength1, value)) SetVerticesDirty(); }
  112. }
  113. /// <summary>
  114. /// The length of the second segment of visual guide line.
  115. /// |视觉引导线第二段的长度。
  116. /// </summary>
  117. public float lineLength2
  118. {
  119. get { return m_LineLength2; }
  120. set { if (PropertyUtil.SetStruct(ref m_LineLength2, value)) SetVerticesDirty(); }
  121. }
  122. /// <summary>
  123. /// The symbol of the start point of labelline.
  124. /// |起始点的图形标记。
  125. /// </summary>
  126. public SymbolStyle startSymbol
  127. {
  128. get { return m_StartSymbol; }
  129. set { if (PropertyUtil.SetClass(ref m_StartSymbol, value)) SetVerticesDirty(); }
  130. }
  131. /// <summary>
  132. /// The symbol of the end point of labelline.
  133. /// |结束点的图形标记。
  134. /// </summary>
  135. public SymbolStyle endSymbol
  136. {
  137. get { return m_EndSymbol; }
  138. set { if (PropertyUtil.SetClass(ref m_EndSymbol, value)) SetVerticesDirty(); }
  139. }
  140. public Vector3 GetStartSymbolOffset()
  141. {
  142. return m_StartSymbol != null && m_StartSymbol.show? m_StartSymbol.offset3 : Vector3.zero;
  143. }
  144. public Vector3 GetEndSymbolOffset()
  145. {
  146. return m_EndSymbol != null && m_EndSymbol.show? m_EndSymbol.offset3 : Vector3.zero;
  147. }
  148. }
  149. }