【version工具】添加配置工具
parent
a2ed23dd24
commit
0d5e49f352
|
@ -230,4 +230,155 @@ namespace GameEditor.FrameTool {
|
|||
}
|
||||
}
|
||||
|
||||
public class VersionTxt
|
||||
{
|
||||
public string subChannel;
|
||||
public string buglyId;
|
||||
public string channel;
|
||||
public string resUrl;
|
||||
public string packageVersion;
|
||||
public string version;
|
||||
public string serverUrl;
|
||||
}
|
||||
|
||||
|
||||
public class VersionWindow : EditorWindow
|
||||
{
|
||||
static string versionPath = Application.dataPath + "/../Version";
|
||||
static string editorVersion = Application.dataPath + "/../AssetBundles/version.txt";
|
||||
static string persistVersion = Application.dataPath + "/Resources/version.txt";
|
||||
static string streamVersion = AppConst.StreamPath + "/Resources/version.txt";
|
||||
|
||||
static VersionTxt m_VersionTxt; // 热更版本
|
||||
|
||||
|
||||
|
||||
static string[] m_Files;
|
||||
static bool[] m_Choose;
|
||||
static string m_Ver;
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem("Build/Version")]
|
||||
static void Init()
|
||||
{
|
||||
LoadVersion(editorVersion);
|
||||
LoadDic();
|
||||
// Get existing open window or if none, make a new one:
|
||||
VersionWindow window = (VersionWindow)EditorWindow.GetWindow(typeof(VersionWindow));
|
||||
window.Show();
|
||||
|
||||
}
|
||||
// 加载version文件
|
||||
private static void LoadVersion(string path)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path) && File.Exists(path))
|
||||
{
|
||||
string json = File.ReadAllText(path);
|
||||
m_VersionTxt = JsonUtility.FromJson<VersionTxt>(json);
|
||||
}
|
||||
if (!path.Equals(editorVersion))
|
||||
{
|
||||
SaveToEditorPath();
|
||||
}
|
||||
}
|
||||
|
||||
// 保存到编辑器路径
|
||||
private static void SaveToEditorPath()
|
||||
{
|
||||
string json = JsonUtility.ToJson(m_VersionTxt);
|
||||
SaveToVersion(editorVersion, json);
|
||||
}
|
||||
// 保存到打包路径
|
||||
private static void SaveToBuildPath()
|
||||
{
|
||||
string json = JsonUtility.ToJson(m_VersionTxt);
|
||||
SaveToVersion(persistVersion, json);
|
||||
SaveToVersion(streamVersion, json);
|
||||
}
|
||||
// 保存到version
|
||||
private static void SaveToVersion(string path, string json)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path) && File.Exists(path))
|
||||
{
|
||||
File.WriteAllText(path, json);
|
||||
}else
|
||||
{
|
||||
UnityEngine.Debug.Log("未找到目标路径:"+path);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载version目录
|
||||
private static void LoadDic()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(versionPath) && Directory.Exists(versionPath))
|
||||
{
|
||||
m_Files = Directory.GetFiles(versionPath, "*", SearchOption.AllDirectories);
|
||||
m_Choose = new bool[m_Files.Length];
|
||||
}
|
||||
}
|
||||
void OnGUI()
|
||||
{
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
EditorGUILayout.LabelField("version文件配置:");
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("登录服地址:");
|
||||
m_VersionTxt.serverUrl = EditorGUILayout.TextField("", m_VersionTxt.serverUrl);
|
||||
EditorGUILayout.LabelField("热更CDN地址:");
|
||||
m_VersionTxt.resUrl = EditorGUILayout.TextField("", m_VersionTxt.resUrl);
|
||||
EditorGUILayout.LabelField("渠道:");
|
||||
m_VersionTxt.channel = EditorGUILayout.TextField("", m_VersionTxt.channel);
|
||||
EditorGUILayout.LabelField("子渠道:");
|
||||
m_VersionTxt.subChannel = EditorGUILayout.TextField("", m_VersionTxt.subChannel);
|
||||
EditorGUILayout.LabelField("包版本号:");
|
||||
m_VersionTxt.packageVersion = EditorGUILayout.TextField("", m_VersionTxt.packageVersion);
|
||||
EditorGUILayout.LabelField("热更版本号:");
|
||||
m_VersionTxt.version = EditorGUILayout.TextField("", m_VersionTxt.version);
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
if (GUILayout.Button("应用", GUILayout.Height(40f)))
|
||||
{
|
||||
SaveToEditorPath();
|
||||
UnityEngine.Debug.Log("应用成功");
|
||||
}
|
||||
EditorGUILayout.BeginVertical();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("请选择要使用的version文件:");
|
||||
if (m_Files != null && m_Files.Length != 0)
|
||||
{
|
||||
for (int i = 0; i < m_Files.Length; i++)
|
||||
{
|
||||
m_Choose[i] = EditorGUILayout.ToggleLeft(Path.GetFileNameWithoutExtension(m_Files[i]), m_Choose[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.LabelField("未找到分支");
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
if (GUILayout.Button("使用选中的version文件", GUILayout.Height(40f)))
|
||||
{
|
||||
for (int i = 0; i < m_Files.Length; i++)
|
||||
{
|
||||
if (m_Choose[i])
|
||||
{
|
||||
LoadVersion(m_Files[i]);
|
||||
UnityEngine.Debug.Log("使用成功");
|
||||
return;
|
||||
}
|
||||
}
|
||||
UnityEngine.Debug.Log("未找到可用的version");
|
||||
}
|
||||
|
||||
|
||||
if (GUILayout.Button("保存到打包路径", GUILayout.Height(40f)))
|
||||
{
|
||||
SaveToBuildPath();
|
||||
UnityEngine.Debug.Log("保存成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{"subChannel":"20201222", "buglyId":"261348dcd3", "channel":"MHT", "resUrl":"http://60.1.1.12/jieling_dl/dev/assetBundles/subChannal094-test/", "packageVersion":"0.2", "version":"0.15.0", "serverUrl":"http://119.29.193.45:8080/"}
|
|
@ -0,0 +1 @@
|
|||
{"buglyId":"261348dcd3", "channel":"37", "resUrl":"http://cdn-jl.lanjingshidai.com/mht_test/", "packageVersion":"0.1", "subChannel":"20201110", "version":"0.1.1", "serverUrl":"http://139.9.223.139:8080/"}
|
|
@ -0,0 +1 @@
|
|||
{"buglyId":"261348dcd3", "channel":"MHT", "resUrl":"http://cdn-jl.lanjingshidai.com/mht_release/", "packageVersion":"0.1", "subChannel":"2000", "version":"0.1.0", "serverUrl":"http://106.52.122.168:8080/"}
|
|
@ -0,0 +1 @@
|
|||
{"buglyId":"261348dcd3", "channel":"MHT", "resUrl":"http://cdn-jl.lanjingshidai.com/mht_test/", "packageVersion":"0.1", "subChannel":"1000", "version":"0.1.0", "serverUrl":"http://106.52.122.168:8080/"}
|
|
@ -0,0 +1 @@
|
|||
{"buglyId":"261348dcd3", "channel":"MHT", "resUrl":"http://jl.tyu89.wang/mht_test/", "packageVersion":"0.1", "subChannel":"20000", "version":"0.1.2", "serverUrl":"http://139.9.223.139:8080/"}
|
|
@ -0,0 +1 @@
|
|||
{"buglyId":"261348dcd3", "channel":"MHT", "resUrl":"http://jl.tyu89.wang/mht/en/", "packageVersion":"0.1", "subChannel":"10000", "version":"0.16.1", "serverUrl":"http://139.9.223.139:8080/"}
|
|
@ -0,0 +1 @@
|
|||
{"subChannel":"2000", "buglyId":"261348dcd3", "channel":"MHT", "resUrl":"http://jl.tyu89.wang/mht_hw_release/", "packageVersion":"0.1", "version":"0.1.1", "serverUrl":"http://119.28.117.110:8080/"}
|
|
@ -0,0 +1 @@
|
|||
{"subChannel":"1000", "buglyId":"261348dcd3", "channel":"MHT", "resUrl":"http://jl.tyu89.wang/mht_hw_test/", "packageVersion":"0.1", "version":"0.1.0", "serverUrl":"http://119.28.117.110:8080/"}
|
|
@ -0,0 +1 @@
|
|||
{"buglyId":"261348dcd3", "channel":"MHT", "resUrl":"http://jl.tyu89.wang/mht/en/", "packageVersion":"0.1", "subChannel":"10000", "version":"0.1.1", "serverUrl":"http://139.9.223.139:8080/"}
|
|
@ -0,0 +1 @@
|
|||
{"subChannel":"888", "buglyId":"b67b061643", "channel":"pc", "resUrl":"http://cdn-jl.lanjingshidai.com/banshu/", "packageVersion":"0.1", "version":"0.1.1", "serverUrl":"http://154.8.225.157:8080/"}
|
Loading…
Reference in New Issue