暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SymbolStyle.cs 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. namespace XCharts.Runtime
  5. {
  6. /// <summary>
  7. /// the type of symbol.
  8. /// |标记图形的类型。
  9. /// </summary>
  10. public enum SymbolType
  11. {
  12. /// <summary>
  13. /// 不显示标记。
  14. /// </summary>
  15. None,
  16. /// <summary>
  17. /// 自定义标记。
  18. /// </summary>
  19. Custom,
  20. /// <summary>
  21. /// 圆形。
  22. /// </summary>
  23. Circle,
  24. /// <summary>
  25. /// 空心圆。
  26. /// </summary>
  27. EmptyCircle,
  28. /// <summary>
  29. /// 正方形。可通过设置`itemStyle`的`cornerRadius`变成圆角矩形。
  30. /// </summary>
  31. Rect,
  32. /// <summary>
  33. /// 空心正方形。
  34. /// </summary>
  35. EmptyRect,
  36. /// <summary>
  37. /// 三角形。
  38. /// </summary>
  39. Triangle,
  40. /// <summary>
  41. /// 空心三角形。
  42. /// </summary>
  43. EmptyTriangle,
  44. /// <summary>
  45. /// 菱形。
  46. /// </summary>
  47. Diamond,
  48. /// <summary>
  49. /// 空心菱形。
  50. /// </summary>
  51. EmptyDiamond,
  52. /// <summary>
  53. /// 箭头。
  54. /// </summary>
  55. Arrow,
  56. /// <summary>
  57. /// 空心箭头。
  58. /// </summary>
  59. EmptyArrow
  60. }
  61. /// <summary>
  62. /// 系列数据项的标记的图形
  63. /// </summary>
  64. [System.Serializable]
  65. public class SymbolStyle : ChildComponent
  66. {
  67. [SerializeField] protected bool m_Show = true;
  68. [SerializeField] protected SymbolType m_Type = SymbolType.EmptyCircle;
  69. [SerializeField] protected float m_Size = 0f;
  70. [SerializeField] protected float m_Gap = 0;
  71. [SerializeField] protected float m_Width = 0f;
  72. [SerializeField] protected float m_Height = 0f;
  73. [SerializeField] protected Vector2 m_Offset = Vector2.zero;
  74. [SerializeField] protected Sprite m_Image;
  75. [SerializeField] protected Image.Type m_ImageType;
  76. [SerializeField] protected Color32 m_Color;
  77. public virtual void Reset()
  78. {
  79. m_Show = false;
  80. m_Type = SymbolType.EmptyCircle;
  81. m_Size = 0f;
  82. m_Gap = 0;
  83. m_Width = 0f;
  84. m_Height = 0f;
  85. m_Offset = Vector2.zero;
  86. m_Image = null;
  87. m_ImageType = Image.Type.Simple;
  88. }
  89. /// <summary>
  90. /// Whether the symbol is showed.
  91. /// |是否显示标记。
  92. /// </summary>
  93. public bool show
  94. {
  95. get { return m_Show; }
  96. set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
  97. }
  98. /// <summary>
  99. /// the type of symbol.
  100. /// |标记类型。
  101. /// </summary>
  102. public SymbolType type
  103. {
  104. get { return m_Type; }
  105. set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
  106. }
  107. /// <summary>
  108. /// the size of symbol.
  109. /// |标记的大小。
  110. /// </summary>
  111. public float size
  112. {
  113. get { return m_Size; }
  114. set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
  115. }
  116. /// <summary>
  117. /// the gap of symbol and line segment.
  118. /// |图形标记和线条的间隙距离。
  119. /// </summary>
  120. public float gap
  121. {
  122. get { return m_Gap; }
  123. set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
  124. }
  125. /// <summary>
  126. /// 图形的宽。
  127. /// </summary>
  128. public float width
  129. {
  130. get { return m_Width; }
  131. set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetAllDirty(); }
  132. }
  133. /// <summary>
  134. /// 图形的高。
  135. /// </summary>
  136. public float height
  137. {
  138. get { return m_Height; }
  139. set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetAllDirty(); }
  140. }
  141. /// <summary>
  142. /// 自定义的标记图形。
  143. /// </summary>
  144. public Sprite image
  145. {
  146. get { return m_Image; }
  147. set { if (PropertyUtil.SetClass(ref m_Image, value)) SetAllDirty(); }
  148. }
  149. /// <summary>
  150. /// the fill type of image.
  151. /// |图形填充类型。
  152. /// </summary>
  153. public Image.Type imageType
  154. {
  155. get { return m_ImageType; }
  156. set { if (PropertyUtil.SetStruct(ref m_ImageType, value)) SetAllDirty(); }
  157. }
  158. /// <summary>
  159. /// 图形的偏移。
  160. /// </summary>
  161. public Vector2 offset
  162. {
  163. get { return m_Offset; }
  164. set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetAllDirty(); }
  165. }
  166. /// <summary>
  167. /// 图形的颜色。
  168. /// </summary>
  169. public Color32 color
  170. {
  171. get { return m_Color; }
  172. set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); }
  173. }
  174. public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
  175. private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
  176. /// <summary>
  177. /// the setting for effect scatter.
  178. /// |带有涟漪特效动画的散点图的动画参数。
  179. /// </summary>
  180. public List<float> animationSize { get { return m_AnimationSize; } }
  181. public Color32 GetColor(Color32 defaultColor)
  182. {
  183. return ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
  184. }
  185. }
  186. }