Brak opisu
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. namespace XCharts.Runtime
  5. {
  6. [RequireComponent(typeof(CanvasRenderer))]
  7. public class Painter : MaskableGraphic
  8. {
  9. public enum Type
  10. {
  11. Base,
  12. Serie,
  13. Top
  14. }
  15. protected int m_Index = -1;
  16. protected Type m_Type = Type.Base;
  17. protected bool m_Refresh;
  18. protected Action<VertexHelper, Painter> m_OnPopulateMesh;
  19. public Action<VertexHelper, Painter> onPopulateMesh { set { m_OnPopulateMesh = value; } }
  20. public int index { get { return m_Index; } set { m_Index = value; } }
  21. public Type type { get { return m_Type; } set { m_Type = value; } }
  22. public void Refresh()
  23. {
  24. if (null == this || gameObject == null) return;
  25. if (!gameObject.activeSelf) return;
  26. m_Refresh = true;
  27. }
  28. public void Init()
  29. {
  30. raycastTarget = false;
  31. }
  32. public void SetActive(bool flag, bool isDebugMode = false)
  33. {
  34. if (gameObject.activeInHierarchy != flag)
  35. {
  36. gameObject.SetActive(flag);
  37. }
  38. var hideFlags = flag && isDebugMode ? HideFlags.None : HideFlags.HideInHierarchy;
  39. if (gameObject.hideFlags != hideFlags)
  40. {
  41. gameObject.hideFlags = hideFlags;
  42. }
  43. }
  44. protected override void Awake()
  45. {
  46. Init();
  47. }
  48. public void CheckRefresh()
  49. {
  50. if (m_Refresh && gameObject.activeSelf)
  51. {
  52. m_Refresh = false;
  53. SetVerticesDirty();
  54. }
  55. }
  56. protected override void OnPopulateMesh(VertexHelper vh)
  57. {
  58. vh.Clear();
  59. if (m_OnPopulateMesh != null)
  60. {
  61. m_OnPopulateMesh(vh, this);
  62. }
  63. }
  64. }
  65. }