暫無描述
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.

Background.cs 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. namespace XCharts.Runtime
  5. {
  6. /// <summary>
  7. /// Background component.
  8. /// |背景组件。
  9. /// </summary>
  10. [Serializable]
  11. [DisallowMultipleComponent]
  12. [ComponentHandler(typeof(BackgroundHandler), false)]
  13. public class Background : MainComponent
  14. {
  15. [SerializeField] private bool m_Show = true;
  16. [SerializeField] private Sprite m_Image;
  17. [SerializeField] private Image.Type m_ImageType;
  18. [SerializeField] private Color m_ImageColor = Color.white;
  19. [SerializeField] private bool m_AutoColor = true;
  20. /// <summary>
  21. /// Whether to enable the background component.
  22. /// |是否启用背景组件。
  23. /// </summary>
  24. public bool show
  25. {
  26. get { return m_Show; }
  27. set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
  28. }
  29. /// <summary>
  30. /// the image of background.
  31. /// |背景图。
  32. /// </summary>
  33. public Sprite image
  34. {
  35. get { return m_Image; }
  36. set { if (PropertyUtil.SetClass(ref m_Image, value)) SetComponentDirty(); }
  37. }
  38. /// <summary>
  39. /// the fill type of background image.
  40. /// |背景图填充类型。
  41. /// </summary>
  42. public Image.Type imageType
  43. {
  44. get { return m_ImageType; }
  45. set { if (PropertyUtil.SetStruct(ref m_ImageType, value)) SetComponentDirty(); }
  46. }
  47. /// <summary>
  48. /// 背景图颜色。
  49. /// </summary>
  50. public Color imageColor
  51. {
  52. get { return m_ImageColor; }
  53. set { if (PropertyUtil.SetColor(ref m_ImageColor, value)) SetComponentDirty(); }
  54. }
  55. /// <summary>
  56. /// Whether to use theme background color for component color when the background component is on.
  57. /// |当background组件开启时,是否自动使用主题背景色作为backgrounnd组件的颜色。当设置为false时,用imageColor作为颜色。
  58. /// </summary>
  59. public bool autoColor
  60. {
  61. get { return m_AutoColor; }
  62. set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetVerticesDirty(); }
  63. }
  64. public override void SetDefaultValue()
  65. {
  66. m_Show = true;
  67. m_Image = null;
  68. m_ImageType = Image.Type.Sliced;
  69. m_ImageColor = Color.white;
  70. m_AutoColor = true;
  71. }
  72. }
  73. }