【热更新工具】
parent
a9ce0d077e
commit
7cb79b4de3
|
@ -177,6 +177,10 @@ namespace GameEditor.FrameTool
|
|||
public bool isCalSize = false; // 判断是否计算过大小了
|
||||
public bool isChoose = false; // 是否被选中
|
||||
|
||||
public string cdn_files_path = "";
|
||||
public string project_files_path = "";
|
||||
public string local_files_path = "";
|
||||
|
||||
public decimal local_cdn_size = 0; // git与cdn比较 热更文件的文件大小
|
||||
public decimal project_cdn_size = 0; // 工程与cdn比较 热更文件的文件大小
|
||||
|
||||
|
@ -204,11 +208,11 @@ namespace GameEditor.FrameTool
|
|||
}
|
||||
|
||||
// cdn上files文件保存的位置
|
||||
string cdn_files_path = path_cdn_setting + "__Download/";
|
||||
cdn_files_path = path_cdn_setting + "__Download/";
|
||||
// 工程中的位置
|
||||
string project_files_path = Application.dataPath + "/../BuildABs/" + AppConst.PlatformPath + "/";
|
||||
project_files_path = Application.dataPath + "/../BuildABs/" + AppConst.PlatformPath + "/";
|
||||
// GIT位置
|
||||
string local_files_path = HotfixWindow._HotFixProjectPath + "/Root/" + dir_name + "/" + AppConst.PlatformPath + "/";
|
||||
local_files_path = HotfixWindow._HotFixProjectPath + "/Root/" + dir_name + "/" + AppConst.PlatformPath + "/";
|
||||
|
||||
// 读取version文件
|
||||
string json = File.ReadAllText(path_cdn_setting + AppConst.GameVersionFile);
|
||||
|
@ -404,6 +408,13 @@ namespace GameEditor.FrameTool
|
|||
{
|
||||
hfs.CalHotFixSize();
|
||||
}
|
||||
if (GUILayout.Button("更新", GUILayout.Height(30f), GUILayout.Width(100f)))
|
||||
{
|
||||
HotfixConfimWindow.Create("是否要热更: " + hfs.desc, hfs.local_cdn_list, () =>
|
||||
{
|
||||
UpdateUnity3dToCDN(hfs);
|
||||
});
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
|
@ -480,6 +491,68 @@ namespace GameEditor.FrameTool
|
|||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
//同步工程中的热更文件到git
|
||||
private static void UpdateUnity3dToCDN(HotFixSetting hfs)
|
||||
{
|
||||
string logName;
|
||||
string updateName;
|
||||
string changeFileName;
|
||||
List<ResourceFile> updateList;
|
||||
List<string> log = new List<string>();
|
||||
updateList = hfs.local_cdn_list;
|
||||
if (updateList.Count <= 0)
|
||||
{
|
||||
UnityEngine.Debug.Log("未检测到文件改动");
|
||||
return;
|
||||
}
|
||||
// 初始化数据
|
||||
updateName = hfs.dir_name + "_" + hfs.dir_cdn_setting + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss");
|
||||
changeFileName = updateName.Replace("/", "$");
|
||||
logName = changeFileName + "_UpLoad";
|
||||
EditorUtility.DisplayProgressBar("正在获取数据:", updateName, 0f);
|
||||
log.Add("热更文件版本:" + updateName);
|
||||
log.Add("热更大小:" + hfs.local_cdn_size);
|
||||
// copy unity3d
|
||||
log.Add("热更文件:");
|
||||
List<string> changeFile = new List<string>();
|
||||
foreach (ResourceFile rf in updateList)
|
||||
{
|
||||
changeFile.Add(rf.fileName);
|
||||
log.Add(rf.fileName);
|
||||
}
|
||||
// write ChangeList
|
||||
EditorUtility.DisplayProgressBar("正在生成文件变化列表", changeFileName, 1f);
|
||||
WriteLog(hfs.path_cdn_setting + "/__HotFixLog", changeFileName, changeFile.ToArray());
|
||||
// upload to cdn
|
||||
EditorUtility.DisplayProgressBar("正在上传热更文件", changeFileName, 1f);
|
||||
string setting = File.ReadAllText(hfs.path_cdn_setting + "Setting.txt", System.Text.Encoding.UTF8);
|
||||
Hashtable info = MiniJSON.jsonDecode(setting) as Hashtable;
|
||||
|
||||
if (!info.ContainsKey("cdn_type"))
|
||||
{
|
||||
UnityEngine.Debug.LogError("CDN配置错误");
|
||||
EditorUtility.ClearProgressBar();
|
||||
return;
|
||||
}
|
||||
log.Add("CDN TYPE: "+ info["cdn_type"]);
|
||||
string toolsDir = _HotFixProjectPath + "/Tools/" + info["cdn_type"];
|
||||
string command = string.Format("python UpLoad.py {0} {1} {2}>>{3}", _HotFixProjectPath + "/Root/" + hfs.dir_name, hfs.dir_cdn_setting, changeFileName, hfs.path_cdn_setting + "__HotFixLog/" + logName + ".log");
|
||||
log.Add("TOOLS DIR: " + toolsDir);
|
||||
log.Add("UPLOAD COMMAND: " + command);
|
||||
ProcessUtil.ProcessCommand(toolsDir, command);
|
||||
|
||||
// write log
|
||||
EditorUtility.DisplayProgressBar("正在生成Log文件:", logName, 1f);
|
||||
WriteLog(hfs.path_cdn_setting + "__HotFixLog", logName, log.ToArray());
|
||||
// git commit
|
||||
string commitName = hfs.desc + "更新:" + updateName;
|
||||
UnityEngine.Debug.LogError("git commit -m " + commitName);
|
||||
EditorUtility.DisplayProgressBar("正在提交到GIT:", commitName, 1f);
|
||||
ProcessUtil.ProcessCommand(hfs.path_cdn_setting, "git add .");
|
||||
ProcessUtil.ProcessCommand(hfs.path_cdn_setting, "git commit -m " + commitName);
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
|
||||
private static void WriteLog(string path, string name, string[] contents)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue