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.

Settings.cs 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using System;
  2. using UnityEngine;
  3. namespace XCharts.Runtime
  4. {
  5. /// <summary>
  6. /// Global parameter setting component. The default value can be used in general, and can be adjusted when necessary.
  7. /// |全局参数设置组件。一般情况下可使用默认值,当有需要时可进行调整。
  8. /// </summary>
  9. [Serializable]
  10. public class Settings : MainComponent
  11. {
  12. [SerializeField] private bool m_Show = true;
  13. [SerializeField][Range(1, 20)] protected int m_MaxPainter = 10;
  14. [SerializeField] protected bool m_ReversePainter = false;
  15. [SerializeField] protected Material m_BasePainterMaterial;
  16. [SerializeField] protected Material m_SeriePainterMaterial;
  17. [SerializeField] protected Material m_UpperPainterMaterial;
  18. [SerializeField] protected Material m_TopPainterMaterial;
  19. [SerializeField][Range(1, 10)] protected float m_LineSmoothStyle = 2.5f;
  20. [SerializeField][Range(1f, 20)] protected float m_LineSmoothness = 2f;
  21. [SerializeField][Range(0.5f, 20)] protected float m_LineSegmentDistance = 3f;
  22. [SerializeField][Range(1, 10)] protected float m_CicleSmoothness = 2f;
  23. [SerializeField] protected float m_LegendIconLineWidth = 2;
  24. [SerializeField] private float[] m_LegendIconCornerRadius = new float[] { 0.25f, 0.25f, 0.25f, 0.25f };
  25. [SerializeField][Since("v3.1.0")] protected float m_AxisMaxSplitNumber = 50;
  26. public bool show { get { return m_Show; } }
  27. /// <summary>
  28. /// max painter.
  29. /// |设定的painter数量。
  30. /// </summary>
  31. public int maxPainter
  32. {
  33. get { return m_MaxPainter; }
  34. set { if (PropertyUtil.SetStruct(ref m_MaxPainter, value < 0 ? 1 : value)) SetVerticesDirty(); }
  35. }
  36. /// <summary>
  37. /// Painter是否逆序。逆序时index大的serie最先绘制。
  38. /// </summary>
  39. public bool reversePainter
  40. {
  41. get { return m_ReversePainter; }
  42. set { if (PropertyUtil.SetStruct(ref m_ReversePainter, value)) SetVerticesDirty(); }
  43. }
  44. /// <summary>
  45. /// Base Pointer 材质球,设置后会影响Axis等。
  46. /// </summary>
  47. public Material basePainterMaterial
  48. {
  49. get { return m_BasePainterMaterial; }
  50. set { if (PropertyUtil.SetClass(ref m_BasePainterMaterial, value)) SetComponentDirty(); }
  51. }
  52. /// <summary>
  53. /// Serie Pointer 材质球,设置后会影响所有Serie。
  54. /// </summary>
  55. public Material seriePainterMaterial
  56. {
  57. get { return m_SeriePainterMaterial; }
  58. set { if (PropertyUtil.SetClass(ref m_SeriePainterMaterial, value)) SetComponentDirty(); }
  59. }
  60. /// <summary>
  61. /// Top Pointer 材质球。
  62. /// </summary>
  63. public Material topPainterMaterial
  64. {
  65. get { return m_TopPainterMaterial; }
  66. set { if (PropertyUtil.SetClass(ref m_TopPainterMaterial, value)) SetComponentDirty(); }
  67. }
  68. /// <summary>
  69. /// Upper Pointer 材质球。
  70. /// </summary>
  71. public Material upperPainterMaterial
  72. {
  73. get { return m_UpperPainterMaterial; }
  74. set { if (PropertyUtil.SetClass(ref m_UpperPainterMaterial, value)) SetComponentDirty(); }
  75. }
  76. /// <summary>
  77. /// Curve smoothing factor. By adjusting the smoothing coefficient, the curvature of the curve can be changed,
  78. /// and different curves with slightly different appearance can be obtained.
  79. /// |曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
  80. /// </summary>
  81. public float lineSmoothStyle
  82. {
  83. get { return m_LineSmoothStyle; }
  84. set { if (PropertyUtil.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
  85. }
  86. /// <summary>
  87. /// Smoothness of curve. The smaller the value, the smoother the curve, but the number of vertices will increase.
  88. /// |When the area with gradient is filled, the larger the value, the worse the transition effect.
  89. /// |曲线平滑度。值越小曲线越平滑,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
  90. /// </summary>
  91. /// <value></value>
  92. public float lineSmoothness
  93. {
  94. get { return m_LineSmoothness; }
  95. set { if (PropertyUtil.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
  96. }
  97. /// <summary>
  98. /// The partition distance of a line segment. A line in a normal line chart is made up of many segments,
  99. /// the number of which is determined by the change in value. The smaller the number of segments,
  100. /// the higher the number of vertices. When the area with gradient is filled, the larger the value, the worse the transition effect.
  101. /// |线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
  102. /// </summary>
  103. /// <value></value>
  104. public float lineSegmentDistance
  105. {
  106. get { return m_LineSegmentDistance; }
  107. set { if (PropertyUtil.SetStruct(ref m_LineSegmentDistance, value < 0 ? 1f : value)) SetVerticesDirty(); }
  108. }
  109. /// <summary>
  110. /// the smoothess of cricle.
  111. /// |圆形的平滑度。数越小圆越平滑,但顶点数也会随之增加。
  112. /// </summary>
  113. public float cicleSmoothness
  114. {
  115. get { return m_CicleSmoothness; }
  116. set { if (PropertyUtil.SetStruct(ref m_CicleSmoothness, value < 0 ? 1f : value)) SetVerticesDirty(); }
  117. }
  118. /// <summary>
  119. /// the width of line serie legend.
  120. /// |Line类型图例图标的线条宽度。
  121. /// </summary>
  122. public float legendIconLineWidth
  123. {
  124. get { return m_LegendIconLineWidth; }
  125. set { if (PropertyUtil.SetStruct(ref m_LegendIconLineWidth, value)) SetVerticesDirty(); }
  126. }
  127. /// <summary>
  128. /// The radius of rounded corner. Its unit is px. Use array to respectively specify the 4 corner radiuses((clockwise upper left, upper right, bottom right and bottom left)).
  129. /// |图例圆角半径。用数组分别指定4个圆角半径(顺时针左上,右上,右下,左下)。
  130. /// </summary>
  131. public float[] legendIconCornerRadius
  132. {
  133. get { return m_LegendIconCornerRadius; }
  134. set { if (PropertyUtil.SetClass(ref m_LegendIconCornerRadius, value, true)) SetVerticesDirty(); }
  135. }
  136. /// <summary>
  137. /// the max splitnumber of axis.
  138. /// |坐标轴最大分隔段数。段数过大时可能会生成较多的label节点。
  139. /// </summary>
  140. public float axisMaxSplitNumber
  141. {
  142. get { return m_AxisMaxSplitNumber; }
  143. set { if (PropertyUtil.SetStruct(ref m_AxisMaxSplitNumber, value)) SetVerticesDirty(); }
  144. }
  145. public void Copy(Settings settings)
  146. {
  147. m_ReversePainter = settings.reversePainter;
  148. m_MaxPainter = settings.maxPainter;
  149. m_BasePainterMaterial = settings.basePainterMaterial;
  150. m_SeriePainterMaterial = settings.seriePainterMaterial;
  151. m_UpperPainterMaterial = settings.upperPainterMaterial;
  152. m_TopPainterMaterial = settings.topPainterMaterial;
  153. m_LineSmoothStyle = settings.lineSmoothStyle;
  154. m_LineSmoothness = settings.lineSmoothness;
  155. m_LineSegmentDistance = settings.lineSegmentDistance;
  156. m_CicleSmoothness = settings.cicleSmoothness;
  157. m_LegendIconLineWidth = settings.legendIconLineWidth;
  158. ChartHelper.CopyArray(m_LegendIconCornerRadius, settings.legendIconCornerRadius);
  159. }
  160. public override void Reset()
  161. {
  162. Copy(DefaultSettings);
  163. }
  164. public static Settings DefaultSettings
  165. {
  166. get
  167. {
  168. return new Settings()
  169. {
  170. m_ReversePainter = false,
  171. m_MaxPainter = XCSettings.maxPainter,
  172. m_LineSmoothStyle = XCSettings.lineSmoothStyle,
  173. m_LineSmoothness = XCSettings.lineSmoothness,
  174. m_LineSegmentDistance = XCSettings.lineSegmentDistance,
  175. m_CicleSmoothness = XCSettings.cicleSmoothness,
  176. m_LegendIconLineWidth = 2,
  177. m_LegendIconCornerRadius = new float[] { 0.25f, 0.25f, 0.25f, 0.25f }
  178. };
  179. }
  180. }
  181. }
  182. }