CheckVersionEditor.cs 4.0 KB

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