Açıklama Yok
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.

Comment.cs 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace XCharts.Runtime
  5. {
  6. /// <summary>
  7. /// comment of chart.
  8. /// |图表注解组件。
  9. /// </summary>
  10. [Serializable]
  11. [ComponentHandler(typeof(CommentHander), true)]
  12. public class Comment : MainComponent, IPropertyChanged
  13. {
  14. [SerializeField] private bool m_Show = true;
  15. [SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
  16. [SerializeField] private CommentMarkStyle m_MarkStyle;
  17. [SerializeField] private List<CommentItem> m_Items = new List<CommentItem>() { new CommentItem() };
  18. /// <summary>
  19. /// Set this to false to prevent the comment from showing.
  20. /// |是否显示注解组件。
  21. /// </summary>
  22. public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
  23. /// <summary>
  24. /// The items of comment.
  25. /// |注解项。每个注解组件可以设置多个注解项。
  26. /// </summary>
  27. public List<CommentItem> items { get { return m_Items; } set { m_Items = value; SetComponentDirty(); } }
  28. /// <summary>
  29. /// The text style of all comments.
  30. /// |所有组件的文本样式。
  31. /// </summary>
  32. public LabelStyle labelStyle
  33. {
  34. get { return m_LabelStyle; }
  35. set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); }
  36. }
  37. /// <summary>
  38. /// The text style of all comments.
  39. /// |所有组件的文本样式。
  40. /// </summary>
  41. public CommentMarkStyle markStyle
  42. {
  43. get { return m_MarkStyle; }
  44. set { if (PropertyUtil.SetClass(ref m_MarkStyle, value)) SetVerticesDirty(); }
  45. }
  46. public LabelStyle GetLabelStyle(int index)
  47. {
  48. if (index >= 0 && index < items.Count)
  49. {
  50. var labelStyle = items[index].labelStyle;
  51. if (labelStyle.show) return labelStyle;
  52. }
  53. return m_LabelStyle;
  54. }
  55. public CommentMarkStyle GetMarkStyle(int index)
  56. {
  57. if (index >= 0 && index < items.Count)
  58. {
  59. var markStyle = items[index].markStyle;
  60. if (markStyle.show) return markStyle;
  61. }
  62. return m_MarkStyle;
  63. }
  64. /// <summary>
  65. /// Callback handling when parameters change.
  66. /// |参数变更时的回调处理。
  67. /// </summary>
  68. public void OnChanged()
  69. {
  70. foreach (var item in items)
  71. {
  72. item.location.OnChanged();
  73. }
  74. }
  75. }
  76. }