No Description
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.

ChildComponent.cs 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using UnityEngine;
  3. namespace XCharts.Runtime
  4. {
  5. [System.Serializable]
  6. public class ChildComponent
  7. {
  8. public virtual int index { get; set; }
  9. [NonSerialized] protected bool m_VertsDirty;
  10. [NonSerialized] protected bool m_ComponentDirty;
  11. [NonSerialized] protected Painter m_Painter;
  12. /// <summary>
  13. /// 图表重绘标记。
  14. /// </summary>
  15. public virtual bool vertsDirty { get { return m_VertsDirty; } }
  16. /// <summary>
  17. /// 组件重新初始化标记。
  18. /// </summary>
  19. public virtual bool componentDirty { get { return m_ComponentDirty; } }
  20. /// <summary>
  21. /// 需要重绘图表或重新初始化组件。
  22. /// </summary>
  23. public bool anyDirty { get { return vertsDirty || componentDirty; } }
  24. public Painter painter { get { return m_Painter; } set { m_Painter = value; } }
  25. public Action refreshComponent { get; set; }
  26. public GameObject gameObject { get; set; }
  27. public static void ClearVerticesDirty(ChildComponent component)
  28. {
  29. if (component != null)
  30. component.ClearVerticesDirty();
  31. }
  32. public static void ClearComponentDirty(ChildComponent component)
  33. {
  34. if (component != null)
  35. component.ClearComponentDirty();
  36. }
  37. public static bool IsVertsDirty(ChildComponent component)
  38. {
  39. return component == null?false : component.vertsDirty;
  40. }
  41. public static bool IsComponentDirty(ChildComponent component)
  42. {
  43. return component == null?false : component.componentDirty;
  44. }
  45. public virtual void SetVerticesDirty()
  46. {
  47. m_VertsDirty = true;
  48. }
  49. public virtual void ClearVerticesDirty()
  50. {
  51. m_VertsDirty = false;
  52. }
  53. public virtual void SetComponentDirty()
  54. {
  55. m_ComponentDirty = true;
  56. }
  57. public virtual void ClearComponentDirty()
  58. {
  59. m_ComponentDirty = false;
  60. }
  61. public virtual void ClearDirty()
  62. {
  63. ClearVerticesDirty();
  64. ClearComponentDirty();
  65. }
  66. public virtual void SetAllDirty()
  67. {
  68. SetVerticesDirty();
  69. SetComponentDirty();
  70. }
  71. }
  72. }