AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
XGrid.cs
1 /************************************************/
2 /* */
3 /* Copyright (c) 2018 - 2021 monitor1394 */
4 /* https://github.com/monitor1394 */
5 /* */
6 /************************************************/
7 
8 using System;
9 using UnityEngine;
10 
11 namespace XCharts
12 {
24  [Serializable]
25  public class Grid : MainComponent
26  {
27  [SerializeField] private bool m_Show = true;
28  [SerializeField] private float m_Left;
29  [SerializeField] private float m_Right;
30  [SerializeField] private float m_Top;
31  [SerializeField] private float m_Bottom;
32  [SerializeField] private Color m_BackgroundColor;
33 
38  public bool show
39  {
40  get { return m_Show; }
41  set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
42  }
47  public float left
48  {
49  get { return m_Left; }
50  set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetAllDirty(); }
51  }
56  public float right
57  {
58  get { return m_Right; }
59  set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetAllDirty(); }
60  }
65  public float top
66  {
67  get { return m_Top; }
68  set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetAllDirty(); }
69  }
74  public float bottom
75  {
76  get { return m_Bottom; }
77  set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
78  }
83  public Color backgroundColor
84  {
85  get { return m_BackgroundColor; }
86  set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
87  }
88  public int index { get; internal set; }
89  public float runtimeX { get; private set; }
90  public float runtimeY { get; private set; }
91  public float runtimeWidth { get; private set; }
92  public float runtimeHeight { get; private set; }
93  public Vector3 runtimePosition { get; private set; }
94 
95  internal void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
96  {
97  var runtimeLeft = left <= 1 ? left * chartWidth : left;
98  var runtimeBottom = bottom <= 1 ? bottom * chartHeight : bottom;
99  var runtimeTop = top <= 1 ? top * chartHeight : top;
100  var runtimeRight = right <= 1 ? right * chartWidth : right;
101  runtimeX = chartX + runtimeLeft;
102  runtimeY = chartY + runtimeBottom;
103  runtimeWidth = chartWidth - runtimeLeft - runtimeRight;
104  runtimeHeight = chartHeight - runtimeTop - runtimeBottom;
105  runtimePosition = new Vector3(runtimeX, runtimeY);
106  }
107 
108  public static Grid defaultGrid
109  {
110  get
111  {
112  var grid = new Grid
113  {
114  m_Show = true,
115  m_Left = 50,
116  m_Right = 30,
117  m_Top = 50,
118  m_Bottom = 30
119  };
120  return grid;
121  }
122  }
123  }
124 }
XCharts.Grid.backgroundColor
Color backgroundColor
Background color of grid, which is transparent by default. 网格背景色,默认透明。
Definition: XGrid.cs:84
XCharts.MainComponent
Definition: ChartComponent.cs:67
XCharts.Grid.bottom
float bottom
Distance between grid component and the bottom side of the container. grid 组件离容器下侧的距离。
Definition: XGrid.cs:75
XCharts
Definition: RewardChart.cs:14
XCharts.Grid.left
float left
Distance between grid component and the left side of the container. grid 组件离容器左侧的距离。
Definition: XGrid.cs:48
XCharts.Grid.right
float right
Distance between grid component and the right side of the container. grid 组件离容器右侧的距离。
Definition: XGrid.cs:57
XCharts.Grid
Grid component. Drawing grid in rectangular coordinate. In a single grid, at most two X and Y axes ea...
Definition: XGrid.cs:25
XCharts.Grid.show
bool show
Whether to show the grid in rectangular coordinate. 是否显示直角坐标系网格。
Definition: XGrid.cs:39
XCharts.Grid.top
float top
Distance between grid component and the top side of the container. grid 组件离容器上侧的距离。
Definition: XGrid.cs:66