AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
ComponentTheme.cs
1 /************************************************/
2 /* */
3 /* Copyright (c) 2018 - 2021 monitor1394 */
4 /* https://github.com/monitor1394 */
5 /* */
6 /************************************************/
7 
8 using System;
9 using UnityEngine;
10 #if dUI_TextMeshPro
11 using TMPro;
12 #endif
13 
14 namespace XCharts
15 {
16  [Serializable]
18  {
19  [SerializeField] protected Font m_Font;
20  [SerializeField] protected Color m_TextColor;
21  [SerializeField] protected Color m_TextBackgroundColor;
22  [SerializeField] protected int m_FontSize = 18;
23 #if dUI_TextMeshPro
24  [SerializeField] protected TMP_FontAsset m_TMPFont;
25 #endif
26 
31  public Font font
32  {
33  get { return m_Font; }
34  set { m_Font = value; SetComponentDirty(); }
35  }
40  public Color textColor
41  {
42  get { return m_TextColor; }
43  set { if (PropertyUtil.SetColor(ref m_TextColor, value)) SetComponentDirty(); }
44  }
49  public Color textBackgroundColor
50  {
51  get { return m_TextBackgroundColor; }
52  set { if (PropertyUtil.SetColor(ref m_TextBackgroundColor, value)) SetComponentDirty(); }
53  }
58  public int fontSize
59  {
60  get { return m_FontSize; }
61  set { if (PropertyUtil.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
62  }
63 
64 #if dUI_TextMeshPro
65  public TMP_FontAsset tmpFont
70  {
71  get { return m_TMPFont; }
72  set { m_TMPFont = value; SetComponentDirty(); }
73  }
74 #endif
75 
76  public ComponentTheme(Theme theme)
77  {
78  m_FontSize = XChartsSettings.fontSizeLv3;
79  switch (theme)
80  {
81  case Theme.Default:
82  m_TextColor = ColorUtil.GetColor("#514D4D");
83  break;
84  case Theme.Light:
85  m_TextColor = ColorUtil.GetColor("#514D4D");
86  break;
87  case Theme.Dark:
88  m_TextColor = ColorUtil.GetColor("#B9B8CE");
89  break;
90  }
91  }
92 
93  public virtual void Copy(ComponentTheme theme)
94  {
95  m_Font = theme.font;
96  m_FontSize = theme.fontSize;
97  m_TextColor = theme.textColor;
98  m_TextBackgroundColor = theme.textBackgroundColor;
99 #if dUI_TextMeshPro
100  m_TMPFont = theme.tmpFont;
101 #endif
102  }
103 
104  public virtual void Reset(ComponentTheme defaultTheme)
105  {
106  Copy(defaultTheme);
107  }
108  }
109 }
XCharts.ComponentTheme.textColor
Color textColor
the color of text. 文本颜色。
Definition: ComponentTheme.cs:41
XCharts.Theme
Theme
主题
Definition: ChartTheme.cs:21
XCharts.MainComponent
Definition: ChartComponent.cs:67
XCharts.ComponentTheme.fontSize
int fontSize
the font size of text. 文本字体大小。
Definition: ComponentTheme.cs:59
XCharts
Definition: RewardChart.cs:14
XCharts.ComponentTheme.textBackgroundColor
Color textBackgroundColor
the color of text. 文本颜色。
Definition: ComponentTheme.cs:50
XCharts.ComponentTheme
Definition: ComponentTheme.cs:17
XCharts.ComponentTheme.font
Font font
the font of text. 字体。
Definition: ComponentTheme.cs:32