VisualMapTheme.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using UnityEngine;
  3. namespace XCharts.Runtime
  4. {
  5. [Serializable]
  6. public class VisualMapTheme : ComponentTheme
  7. {
  8. [SerializeField] protected float m_BorderWidth;
  9. [SerializeField] protected Color32 m_BorderColor;
  10. [SerializeField] protected Color32 m_BackgroundColor;
  11. [SerializeField][Range(10, 50)] protected float m_TriangeLen = 20f;
  12. /// <summary>
  13. /// the width of border.
  14. /// ||边框线宽。
  15. /// </summary>
  16. public float borderWidth
  17. {
  18. get { return m_BorderWidth; }
  19. set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
  20. }
  21. /// <summary>
  22. /// the color of dataZoom border.
  23. /// ||边框颜色。
  24. /// </summary>
  25. public Color32 borderColor
  26. {
  27. get { return m_BorderColor; }
  28. set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetComponentDirty(); }
  29. }
  30. /// <summary>
  31. /// the background color of visualmap.
  32. /// ||背景颜色。
  33. /// </summary>
  34. public Color32 backgroundColor
  35. {
  36. get { return m_BackgroundColor; }
  37. set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetComponentDirty(); }
  38. }
  39. /// <summary>
  40. /// 可视化组件的调节三角形边长。
  41. /// </summary>
  42. public float triangeLen
  43. {
  44. get { return m_TriangeLen; }
  45. set { if (PropertyUtil.SetStruct(ref m_TriangeLen, value < 0 ? 1f : value)) SetVerticesDirty(); }
  46. }
  47. public VisualMapTheme(ThemeType theme) : base(theme)
  48. {
  49. m_BorderWidth = XCSettings.visualMapBorderWidth;
  50. m_TriangeLen = XCSettings.visualMapTriangeLen;
  51. m_FontSize = XCSettings.fontSizeLv4;
  52. switch (theme)
  53. {
  54. case ThemeType.Default:
  55. m_TextColor = ColorUtil.GetColor("#333");
  56. m_BorderColor = ColorUtil.GetColor("#ccc");
  57. m_BackgroundColor = ColorUtil.clearColor32;
  58. break;
  59. case ThemeType.Light:
  60. m_TextColor = ColorUtil.GetColor("#333");
  61. m_BorderColor = ColorUtil.GetColor("#ccc");
  62. m_BackgroundColor = ColorUtil.clearColor32;
  63. break;
  64. case ThemeType.Dark:
  65. m_TextColor = ColorUtil.GetColor("#B9B8CE");
  66. m_BorderColor = ColorUtil.GetColor("#ccc");
  67. m_BackgroundColor = ColorUtil.clearColor32;
  68. break;
  69. }
  70. }
  71. public void Copy(VisualMapTheme theme)
  72. {
  73. base.Copy(theme);
  74. m_TriangeLen = theme.triangeLen;
  75. m_BorderWidth = theme.borderWidth;
  76. m_BorderColor = theme.borderColor;
  77. m_BackgroundColor = theme.backgroundColor;
  78. }
  79. }
  80. }