mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 17:30:10 +00:00
优化版本更新检测
This commit is contained in:
@@ -112,15 +112,19 @@ namespace XCharts
|
||||
|
||||
private void CheckWarning()
|
||||
{
|
||||
if (GUILayout.Button("Check Update "))
|
||||
{
|
||||
CheckVersionEditor.ShowWindow();
|
||||
}
|
||||
if (m_CheckWarning)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Check warning"))
|
||||
if (GUILayout.Button("Check Warning"))
|
||||
{
|
||||
m_CheckWarning = true;
|
||||
m_Target.CheckWarning();
|
||||
}
|
||||
if (GUILayout.Button("Hide warning"))
|
||||
if (GUILayout.Button("Hide Warning"))
|
||||
{
|
||||
m_CheckWarning = false;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace XCharts
|
||||
private static CheckVersionEditor window;
|
||||
|
||||
[MenuItem("Component/XCharts/Check For Update")]
|
||||
private static void ShowWindow()
|
||||
public static void ShowWindow()
|
||||
{
|
||||
window = GetWindow<CheckVersionEditor>();
|
||||
window.titleContent = new GUIContent("XCharts Check For Update");
|
||||
@@ -25,6 +25,11 @@ namespace XCharts
|
||||
XChartsMgr.Instance.CheckVersion();
|
||||
}
|
||||
|
||||
void OnInspectorUpdate()
|
||||
{
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
var mgr = XChartsMgr.Instance;
|
||||
@@ -32,27 +37,38 @@ namespace XCharts
|
||||
GUILayout.Label("当前版本:" + mgr.nowVersion);
|
||||
if (mgr.needUpdate && !mgr.isCheck)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("最新版本:" + mgr.newVersion);
|
||||
GUILayout.Label("");
|
||||
if (mgr.isCheck) GUILayout.Label("检测中...");
|
||||
else if (mgr.isNetworkError) GUILayout.Label("检测失败:" + mgr.networkError);
|
||||
else GUILayout.Label("有更新!");
|
||||
if (GUILayout.Button("去Github主页"))
|
||||
else
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
|
||||
GUILayout.Label("有更新!");
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Label("");
|
||||
if (!string.IsNullOrEmpty(mgr.desc))
|
||||
{
|
||||
GUILayout.Label(mgr.desc);
|
||||
GUILayout.Label("");
|
||||
}
|
||||
|
||||
scrollPos = GUILayout.BeginScrollView(scrollPos);
|
||||
GUILayout.TextArea(mgr.changeLog);
|
||||
GUILayout.EndScrollView();
|
||||
if (GUILayout.Button("去Github主页"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
|
||||
}
|
||||
if (GUILayout.Button("点Star支持"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
|
||||
}
|
||||
if (GUILayout.Button("问题反馈"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(mgr.changeLog))
|
||||
{
|
||||
scrollPos = GUILayout.BeginScrollView(scrollPos);
|
||||
GUILayout.TextArea(mgr.changeLog);
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -69,11 +85,18 @@ namespace XCharts
|
||||
if (!string.IsNullOrEmpty(mgr.desc))
|
||||
{
|
||||
GUILayout.Label(mgr.desc);
|
||||
GUILayout.Label("");
|
||||
}
|
||||
if (GUILayout.Button("去Github主页"))
|
||||
{
|
||||
Application.OpenURL(mgr.homepage);
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
|
||||
}
|
||||
if (GUILayout.Button("点Star支持"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
|
||||
}
|
||||
if (GUILayout.Button("问题反馈"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
|
||||
}
|
||||
if (mgr.isNetworkError && GUILayout.Button("重新检测"))
|
||||
{
|
||||
|
||||
62
Editor/XChartMgrEditor.cs
Normal file
62
Editor/XChartMgrEditor.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI XChartsMgr.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(XChartsMgr), false)]
|
||||
public class XChartsMgrEditor : Editor
|
||||
{
|
||||
protected XChartsMgr m_Target;
|
||||
protected SerializedProperty m_Script;
|
||||
protected SerializedProperty m_NowVersion;
|
||||
protected SerializedProperty m_NewVersion;
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
m_Target = (XChartsMgr)target;
|
||||
m_Script = serializedObject.FindProperty("m_Script");
|
||||
m_NowVersion = serializedObject.FindProperty("m_NowVersion");
|
||||
m_NewVersion = serializedObject.FindProperty("m_NewVersion");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (m_Target == null && target == null)
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
return;
|
||||
}
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(m_NowVersion);
|
||||
EditorGUILayout.PropertyField(m_NewVersion);
|
||||
if (GUILayout.Button("检测更新"))
|
||||
{
|
||||
CheckVersionEditor.ShowWindow();
|
||||
}
|
||||
if (GUILayout.Button("去Github主页"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
|
||||
}
|
||||
if (GUILayout.Button("点Star支持"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
|
||||
}
|
||||
if (GUILayout.Button("问题反馈"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
|
||||
}
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/XChartMgrEditor.cs.meta
Normal file
11
Editor/XChartMgrEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69cbbe551cf1f45c984e6b4febc9f697
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user