AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
Painter.cs
1 /************************************************/
2 /* */
3 /* Copyright (c) 2018 - 2021 monitor1394 */
4 /* https://github.com/monitor1394 */
5 /* */
6 /************************************************/
7 
8 using UnityEngine;
9 using UnityEngine.UI;
10 using System;
11 
12 namespace XCharts
13 {
14  [RequireComponent(typeof(CanvasRenderer))]
15  public class Painter : MaskableGraphic
16  {
17  public enum Type
18  {
19  Base,
20  Serie,
21  Top
22  }
23  protected int m_Index = -1;
24  protected Type m_Type = Type.Base;
25  protected bool m_Refresh;
26  protected Action<VertexHelper, Painter> m_OnPopulateMesh;
27 
28  public Action<VertexHelper, Painter> onPopulateMesh { set { m_OnPopulateMesh = value; } }
29  public int index { get { return m_Index; } set { m_Index = value; } }
30  public Type type { get { return m_Type; } set { m_Type = value; } }
31  public void Refresh()
32  {
33  if (gameObject == null) return;
34  if (!gameObject.activeSelf) return;
35  m_Refresh = true;
36  }
37 
38  public void Init()
39  {
40  raycastTarget = false;
41  }
42 
43  public void SetActive(bool flag, bool isDebugMode = false)
44  {
45  if (gameObject.activeInHierarchy != flag)
46  {
47  gameObject.SetActive(flag);
48  }
49  var hideFlags = flag && isDebugMode ? HideFlags.None : HideFlags.HideInHierarchy;
50  if (gameObject.hideFlags != hideFlags)
51  {
52  gameObject.hideFlags = hideFlags;
53  }
54  }
55 
56  protected override void Awake()
57  {
58  Init();
59  }
60 
61  internal void CheckRefresh()
62  {
63  if (m_Refresh && gameObject.activeSelf)
64  {
65  m_Refresh = false;
66  SetVerticesDirty();
67  }
68  }
69 
70  protected override void OnPopulateMesh(VertexHelper vh)
71  {
72  vh.Clear();
73  if (m_OnPopulateMesh != null)
74  {
75  m_OnPopulateMesh(vh, this);
76  }
77  }
78  }
79 }
XCharts.Painter
Definition: Painter.cs:15
XCharts
Definition: RewardChart.cs:14
XCharts.Serie
系列。每个系列通过 type 决定自己的图表类型。
Definition: Serie.cs:261