Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

IconStyle.cs 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace XCharts.Runtime
  4. {
  5. [System.Serializable]
  6. public class IconStyle : ChildComponent
  7. {
  8. public enum Layer
  9. {
  10. /// <summary>
  11. /// The icon is display under the label text.
  12. /// 图标在标签文字下
  13. /// </summary>
  14. UnderText,
  15. /// <summary>
  16. /// The icon is display above the label text.
  17. /// 图标在标签文字上
  18. /// </summary>
  19. AboveText
  20. }
  21. [SerializeField] private bool m_Show = false;
  22. [SerializeField] private Layer m_Layer;
  23. [SerializeField] private Align m_Align = Align.Left;
  24. [SerializeField] private Sprite m_Sprite;
  25. [SerializeField] private Image.Type m_Type;
  26. [SerializeField] private Color m_Color = Color.white;
  27. [SerializeField] private float m_Width = 20;
  28. [SerializeField] private float m_Height = 20;
  29. [SerializeField] private Vector3 m_Offset;
  30. [SerializeField] private bool m_AutoHideWhenLabelEmpty = false;
  31. public void Reset()
  32. {
  33. m_Show = false;
  34. m_Layer = Layer.UnderText;
  35. m_Sprite = null;
  36. m_Color = Color.white;
  37. m_Width = 20;
  38. m_Height = 20;
  39. m_Offset = Vector3.zero;
  40. m_AutoHideWhenLabelEmpty = false;
  41. }
  42. /// <summary>
  43. /// Whether the data icon is show.
  44. /// |是否显示图标。
  45. /// </summary>
  46. public bool show { get { return m_Show; } set { m_Show = value; } }
  47. /// <summary>
  48. /// 显示在上层还是在下层。
  49. /// </summary>
  50. public Layer layer { get { return m_Layer; } set { m_Layer = value; } }
  51. /// <summary>
  52. /// The image of icon.
  53. /// |图标的图片。
  54. /// </summary>
  55. public Sprite sprite { get { return m_Sprite; } set { m_Sprite = value; } }
  56. /// <summary>
  57. /// How to display the icon.
  58. /// |图片的显示类型。
  59. /// </summary>
  60. public Image.Type type { get { return m_Type; } set { m_Type = value; } }
  61. /// <summary>
  62. /// 图标颜色。
  63. /// </summary>
  64. public Color color { get { return m_Color; } set { m_Color = value; } }
  65. /// <summary>
  66. /// 图标宽。
  67. /// </summary>
  68. public float width { get { return m_Width; } set { m_Width = value; } }
  69. /// <summary>
  70. /// 图标高。
  71. /// </summary>
  72. public float height { get { return m_Height; } set { m_Height = value; } }
  73. /// <summary>
  74. /// 图标偏移。
  75. /// </summary>
  76. public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
  77. /// <summary>
  78. /// 水平方向对齐方式。
  79. /// </summary>
  80. public Align align { get { return m_Align; } set { m_Align = value; } }
  81. /// <summary>
  82. /// 当label内容为空时是否自动隐藏图标
  83. /// </summary>
  84. public bool autoHideWhenLabelEmpty { get { return m_AutoHideWhenLabelEmpty; } set { m_AutoHideWhenLabelEmpty = value; } }
  85. public IconStyle Clone()
  86. {
  87. var iconStyle = new IconStyle();
  88. iconStyle.show = show;
  89. iconStyle.layer = layer;
  90. iconStyle.sprite = sprite;
  91. iconStyle.type = type;
  92. iconStyle.color = color;
  93. iconStyle.width = width;
  94. iconStyle.height = height;
  95. iconStyle.offset = offset;
  96. iconStyle.align = align;
  97. iconStyle.autoHideWhenLabelEmpty = autoHideWhenLabelEmpty;
  98. return iconStyle;
  99. }
  100. public void Copy(IconStyle iconStyle)
  101. {
  102. show = iconStyle.show;
  103. layer = iconStyle.layer;
  104. sprite = iconStyle.sprite;
  105. type = iconStyle.type;
  106. color = iconStyle.color;
  107. width = iconStyle.width;
  108. height = iconStyle.height;
  109. offset = iconStyle.offset;
  110. align = iconStyle.align;
  111. autoHideWhenLabelEmpty = iconStyle.autoHideWhenLabelEmpty;
  112. }
  113. }
  114. }