AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
CheckVersionEditor.cs
1 /************************************************/
2 /* */
3 /* Copyright (c) 2018 - 2021 monitor1394 */
4 /* https://github.com/monitor1394 */
5 /* */
6 /************************************************/
7 
8 using UnityEditor;
9 using UnityEngine;
10 
11 namespace XCharts
12 {
13  public class CheckVersionEditor : EditorWindow
14  {
15  private Vector2 scrollPos;
16  private static CheckVersionEditor window;
17 
18  [MenuItem("XCharts/Upgrade Check")]
19  public static void ShowWindow()
20  {
21  window = GetWindow<CheckVersionEditor>();
22  window.titleContent = new GUIContent("XCharts Upgrade Check");
23  window.minSize = new Vector2(550, window.minSize.y);
24  window.Show();
25  XChartsMgr.Instance.CheckVersion();
26  }
27 
28  void OnInspectorUpdate()
29  {
30  Repaint();
31  }
32 
33  private void OnGUI()
34  {
35  var mgr = XChartsMgr.Instance;
36  GUILayout.Label("");
37  GUILayout.Label("The current version: " + mgr.nowVersion);
38  if (mgr.needUpdate && !mgr.isCheck)
39  {
40  GUILayout.Label("The remote version: " + mgr.newVersion);
41  GUILayout.Label("");
42  if (mgr.isCheck) GUILayout.Label("check ...");
43  else if (mgr.isNetworkError) GUILayout.Label("check failed: " + mgr.networkError);
44  else
45  {
46  GUILayout.Label("There is a new version to upgrade!");
47  }
48 
49  GUILayout.Label("");
50  if (!string.IsNullOrEmpty(mgr.desc))
51  {
52  GUILayout.Label(mgr.desc);
53  }
54  if (GUILayout.Button("Github Homepage"))
55  {
56  Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
57  }
58  if (GUILayout.Button("Star Support"))
59  {
60  Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
61  }
62  if (GUILayout.Button("Issues"))
63  {
64  Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
65  }
66  if (!string.IsNullOrEmpty(mgr.changeLog))
67  {
68  scrollPos = GUILayout.BeginScrollView(scrollPos);
69  GUILayout.TextArea(mgr.changeLog);
70  GUILayout.EndScrollView();
71  }
72  }
73  else
74  {
75  if (mgr.isCheck) GUILayout.Label("The remote version: checking ...");
76  else if (mgr.isNetworkError) GUILayout.Label("check failed: " + mgr.networkError);
77  else GUILayout.Label("The remote version: " + mgr.newVersion);
78 
79  GUILayout.Label("");
80  if (!mgr.isNetworkError && !mgr.needUpdate && !mgr.isCheck)
81  {
82  GUILayout.Label("It is the latest version!");
83  }
84  GUILayout.Label("");
85  if (!string.IsNullOrEmpty(mgr.desc))
86  {
87  GUILayout.Label(mgr.desc);
88  }
89  if (GUILayout.Button("Github Homepage"))
90  {
91  Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
92  }
93  if (GUILayout.Button("Star Support"))
94  {
95  Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
96  }
97  if (GUILayout.Button("Issues"))
98  {
99  Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
100  }
101  if (mgr.isNetworkError && GUILayout.Button("Check Again"))
102  {
103  XChartsMgr.Instance.CheckVersion();
104  }
105  }
106  }
107  }
108 }
XCharts.CheckVersionEditor
Definition: CheckVersionEditor.cs:13
XCharts
Definition: RewardChart.cs:14
XCharts.XChartsMgr
Definition: XChartsMgr.cs:34