2021-05-31 11:24:20 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using GameEditor.Core;
|
|
|
|
|
|
using GameEditor.GameEditor.PlayerBuilder;
|
|
|
|
|
|
using GameEditor.Util;
|
|
|
|
|
|
using GameLogic;
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
using ResUpdate;
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Net;
|
2021-06-07 10:39:27 +08:00
|
|
|
|
using System;
|
2021-05-31 11:24:20 +08:00
|
|
|
|
|
2021-06-07 10:39:27 +08:00
|
|
|
|
namespace GameEditor.FrameTool
|
|
|
|
|
|
{
|
2021-05-31 11:24:20 +08:00
|
|
|
|
public static class HotFixTool
|
|
|
|
|
|
{
|
|
|
|
|
|
//重新下载外部.unity3d文件
|
2021-06-07 10:39:27 +08:00
|
|
|
|
public static void RegetExternalFile(string resUrl, string outPath, string fileName)
|
2021-05-31 11:24:20 +08:00
|
|
|
|
{
|
|
|
|
|
|
//获取下载文件链接
|
2021-06-07 10:39:27 +08:00
|
|
|
|
string url = resUrl + "/" + fileName;
|
|
|
|
|
|
string dlPath = outPath + "/" + fileName;
|
2021-05-31 11:24:20 +08:00
|
|
|
|
// 文件夹没有就创建
|
|
|
|
|
|
if (!Directory.Exists(outPath))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(outPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
//获取文件存放路径
|
|
|
|
|
|
if (File.Exists(dlPath))
|
|
|
|
|
|
{
|
|
|
|
|
|
File.Delete(dlPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 设置参数
|
|
|
|
|
|
UnityEngine.Debug.Log(url);
|
2021-06-11 19:24:04 +08:00
|
|
|
|
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
2021-05-31 11:24:20 +08:00
|
|
|
|
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
|
|
|
|
|
//发送请求并获取相应回应数据
|
|
|
|
|
|
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
|
|
|
|
|
|
//直到request.GetResponse()程序才开始向目标网页发送Post请求
|
|
|
|
|
|
Stream responseStream = response.GetResponseStream();
|
|
|
|
|
|
//创建本地文件写入流
|
|
|
|
|
|
Stream stream = new FileStream(dlPath, FileMode.Create, FileAccess.Write);
|
|
|
|
|
|
byte[] bArr = new byte[1024];
|
|
|
|
|
|
int size = responseStream.Read(bArr, 0, (int)bArr.Length);
|
|
|
|
|
|
while (size > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
stream.Write(bArr, 0, size);
|
|
|
|
|
|
size = responseStream.Read(bArr, 0, (int)bArr.Length);
|
|
|
|
|
|
}
|
|
|
|
|
|
stream.Close();
|
|
|
|
|
|
responseStream.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//遍历内部unity3d数据
|
|
|
|
|
|
public static List<ResourceFile> GetFilesList(string filesPath)
|
|
|
|
|
|
{
|
|
|
|
|
|
UnityEngine.AssetBundle bundle = UnityEngine.AssetBundle.LoadFromFile(filesPath + UpdateConfigs.FILES);
|
|
|
|
|
|
ResourceFiles files = bundle.LoadAsset<ResourceFiles>("game");
|
|
|
|
|
|
bundle.Unload(true);
|
|
|
|
|
|
return files.files;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取差异文件list
|
|
|
|
|
|
public static List<ResourceFile> GetDiffList(List<ResourceFile> inDataList, List<ResourceFile> exDataList)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<ResourceFile> diffList = new List<ResourceFile>();
|
|
|
|
|
|
Dictionary<string, ResourceFile> exDataDic = new Dictionary<string, ResourceFile>();
|
|
|
|
|
|
for (int i = 0; i < exDataList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!exDataDic.ContainsKey(exDataList[i].fileName))
|
|
|
|
|
|
{
|
|
|
|
|
|
exDataDic.Add(exDataList[i].fileName, exDataList[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
exDataDic[exDataList[i].fileName] = exDataList[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < inDataList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!exDataDic.ContainsKey(inDataList[i].fileName))
|
|
|
|
|
|
{
|
|
|
|
|
|
diffList.Add(inDataList[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!inDataList[i].crc.Equals(exDataDic[inDataList[i].fileName].crc))
|
|
|
|
|
|
{
|
|
|
|
|
|
diffList.Add(inDataList[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return diffList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 计算大小
|
|
|
|
|
|
public static decimal GetDiffSize(List<ResourceFile> diffList)
|
|
|
|
|
|
{
|
|
|
|
|
|
decimal size = 0;
|
2021-06-07 10:39:27 +08:00
|
|
|
|
foreach (ResourceFile rf in diffList)
|
2021-05-31 11:24:20 +08:00
|
|
|
|
{
|
|
|
|
|
|
size += rf.size;
|
|
|
|
|
|
}
|
|
|
|
|
|
return size / 1048576;
|
|
|
|
|
|
}
|
2021-06-18 16:03:27 +08:00
|
|
|
|
|
|
|
|
|
|
public static void WriteLog(string path, string name, string[] contents)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
UnityEngine.Debug.Log("创建log文件");
|
|
|
|
|
|
UnityEngine.Debug.Log(path);
|
|
|
|
|
|
UnityEngine.Debug.Log(name);
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
|
}
|
|
|
|
|
|
string filePath = Path.Combine(path, name) + ".log";
|
|
|
|
|
|
//if (!File.Exists(filePath))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// File.Create(filePath).Close();
|
|
|
|
|
|
//}
|
|
|
|
|
|
File.WriteAllLines(filePath, contents);
|
|
|
|
|
|
}
|
2021-05-31 11:24:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class HotFixConfig
|
|
|
|
|
|
{
|
|
|
|
|
|
public string desc;
|
|
|
|
|
|
public string dir_name;
|
|
|
|
|
|
public bool isCalSize = false;
|
|
|
|
|
|
public bool isChoose = false;
|
|
|
|
|
|
|
|
|
|
|
|
public List<HotFixSetting> hotFixSettings;
|
|
|
|
|
|
|
2021-06-07 10:39:27 +08:00
|
|
|
|
public string project_files_path;
|
|
|
|
|
|
public string local_files_path;
|
|
|
|
|
|
|
2021-05-31 11:24:20 +08:00
|
|
|
|
public decimal project_local_size = 0;
|
|
|
|
|
|
public List<ResourceFile> project_local_list;
|
|
|
|
|
|
|
|
|
|
|
|
public HotFixConfig(string _dir_name)
|
|
|
|
|
|
{
|
|
|
|
|
|
desc = _dir_name;
|
|
|
|
|
|
dir_name = _dir_name;
|
|
|
|
|
|
|
|
|
|
|
|
hotFixSettings = new List<HotFixSetting>();
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
isCalSize = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 添加配置文件夹
|
|
|
|
|
|
public void AddSetting(string _desc, string _dir_name, string _dir_cdn_setting)
|
|
|
|
|
|
{
|
|
|
|
|
|
hotFixSettings.Add(new HotFixSetting(_desc, _dir_name, _dir_cdn_setting));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 计算本地到工程的大小
|
|
|
|
|
|
public void CalHotFixSize()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (HotfixWindow._HotFixProjectPath.Equals(""))
|
|
|
|
|
|
{
|
|
|
|
|
|
UnityEngine.Debug.LogError("热更工程路径为空!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2021-06-07 10:39:27 +08:00
|
|
|
|
|
2021-05-31 11:24:20 +08:00
|
|
|
|
// 工程中的位置
|
2021-06-07 10:39:27 +08:00
|
|
|
|
project_files_path = Application.dataPath + "/../BuildABs/" + AppConst.PlatformPath + "/";
|
2021-05-31 11:24:20 +08:00
|
|
|
|
// GIT位置
|
2021-06-07 10:39:27 +08:00
|
|
|
|
local_files_path = HotfixWindow._HotFixProjectPath + "/Root/" + dir_name + "/" + AppConst.PlatformPath + "/";
|
|
|
|
|
|
|
2021-05-31 11:24:20 +08:00
|
|
|
|
// 计算差异文件
|
|
|
|
|
|
project_local_list = HotFixTool.GetDiffList(HotFixTool.GetFilesList(project_files_path), HotFixTool.GetFilesList(local_files_path));
|
|
|
|
|
|
|
|
|
|
|
|
// 计算大小
|
|
|
|
|
|
project_local_size = HotFixTool.GetDiffSize(project_local_list);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
isCalSize = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class HotFixSetting
|
|
|
|
|
|
{
|
|
|
|
|
|
public string desc; // 设置描述
|
|
|
|
|
|
public string dir_name; // 热更分支文件夹
|
|
|
|
|
|
public string dir_cdn_setting; // cdn设置文件夹
|
|
|
|
|
|
public string path_cdn_setting;// cdn设置文件夹全路径
|
|
|
|
|
|
|
|
|
|
|
|
public bool isCalSize = false; // 判断是否计算过大小了
|
|
|
|
|
|
public bool isChoose = false; // 是否被选中
|
2021-06-07 10:39:27 +08:00
|
|
|
|
|
2021-06-11 12:46:14 +08:00
|
|
|
|
public string cdn_files_path = "";
|
|
|
|
|
|
public string project_files_path = "";
|
|
|
|
|
|
public string local_files_path = "";
|
|
|
|
|
|
|
2021-05-31 11:24:20 +08:00
|
|
|
|
public decimal local_cdn_size = 0; // git与cdn比较 热更文件的文件大小
|
|
|
|
|
|
public List<ResourceFile> local_cdn_list; // git与cdn比较 热更文件列表
|
|
|
|
|
|
|
|
|
|
|
|
public VersionTxt local_version;
|
2021-06-07 10:39:27 +08:00
|
|
|
|
public VersionTxt cdn_version;
|
2021-06-18 16:03:27 +08:00
|
|
|
|
public Hashtable cdn_setting;
|
2021-05-31 11:24:20 +08:00
|
|
|
|
|
|
|
|
|
|
public HotFixSetting(string _desc, string _dir_name, string _dir_cdn_setting)
|
|
|
|
|
|
{
|
|
|
|
|
|
desc = _desc;
|
|
|
|
|
|
dir_name = _dir_name;
|
|
|
|
|
|
dir_cdn_setting = _dir_cdn_setting;
|
|
|
|
|
|
path_cdn_setting = HotfixWindow._HotFixProjectPath + "/Root/" + dir_name + "/" + dir_cdn_setting + "/";
|
|
|
|
|
|
isCalSize = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CalHotFixSize()
|
|
|
|
|
|
{
|
2021-06-07 10:39:27 +08:00
|
|
|
|
if (HotfixWindow._HotFixProjectPath.Equals(""))
|
|
|
|
|
|
{
|
2021-05-31 11:24:20 +08:00
|
|
|
|
UnityEngine.Debug.LogError("热更工程路径为空!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// cdn上files文件保存的位置
|
2021-06-11 12:46:14 +08:00
|
|
|
|
cdn_files_path = path_cdn_setting + "__Download/";
|
2021-05-31 11:24:20 +08:00
|
|
|
|
// 工程中的位置
|
2021-06-11 12:46:14 +08:00
|
|
|
|
project_files_path = Application.dataPath + "/../BuildABs/" + AppConst.PlatformPath + "/";
|
2021-05-31 11:24:20 +08:00
|
|
|
|
// GIT位置
|
2021-06-11 12:46:14 +08:00
|
|
|
|
local_files_path = HotfixWindow._HotFixProjectPath + "/Root/" + dir_name + "/" + AppConst.PlatformPath + "/";
|
2021-05-31 11:24:20 +08:00
|
|
|
|
|
2021-06-18 16:03:27 +08:00
|
|
|
|
LoadSetting();
|
|
|
|
|
|
LoadLocalVersion();
|
|
|
|
|
|
LoadCDN();
|
2021-05-31 11:24:20 +08:00
|
|
|
|
|
|
|
|
|
|
// 计算差异文件
|
|
|
|
|
|
local_cdn_list = HotFixTool.GetDiffList(HotFixTool.GetFilesList(local_files_path), HotFixTool.GetFilesList(cdn_files_path));
|
|
|
|
|
|
|
|
|
|
|
|
// 计算大小
|
|
|
|
|
|
local_cdn_size = HotFixTool.GetDiffSize(local_cdn_list);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
isCalSize = true;
|
|
|
|
|
|
}
|
2021-06-18 16:03:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void LoadSetting()
|
|
|
|
|
|
{
|
|
|
|
|
|
string setting = File.ReadAllText(path_cdn_setting + "Setting.txt", System.Text.Encoding.UTF8);
|
|
|
|
|
|
cdn_setting = MiniJSON.jsonDecode(setting) as Hashtable;
|
|
|
|
|
|
}
|
|
|
|
|
|
public string GetSettingConfig(string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cdn_setting == null || !cdn_setting.ContainsKey(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
return cdn_setting[key] as string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void LoadLocalVersion()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 读取version文件
|
|
|
|
|
|
string json = File.ReadAllText(path_cdn_setting + AppConst.GameVersionFile);
|
|
|
|
|
|
local_version = JsonUtility.FromJson<VersionTxt>(json);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void LoadCDN()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(local_version == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UnityEngine.Debug.LogError("请先加载本地version文件");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 下载cdn上的files文件
|
|
|
|
|
|
HotFixTool.RegetExternalFile(local_version.resUrl + AppConst.PlatformPath, cdn_files_path, "files.unity3d");
|
|
|
|
|
|
// 下载version文件
|
|
|
|
|
|
HotFixTool.RegetExternalFile(local_version.resUrl + AppConst.PlatformPath, cdn_files_path, AppConst.GameVersionFile);
|
|
|
|
|
|
// 读取version
|
|
|
|
|
|
string json = File.ReadAllText(cdn_files_path + AppConst.GameVersionFile);
|
|
|
|
|
|
cdn_version = JsonUtility.FromJson<VersionTxt>(json);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void DOUpload()
|
|
|
|
|
|
{
|
|
|
|
|
|
string logName;
|
|
|
|
|
|
string updateName;
|
|
|
|
|
|
string changeFileName;
|
|
|
|
|
|
string logPath = path_cdn_setting + "/__HotFixLog/";
|
|
|
|
|
|
string tagName;
|
|
|
|
|
|
List<string> log = new List<string>();
|
|
|
|
|
|
//if (local_cdn_list.Count <= 0)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// UnityEngine.Debug.Log("未检测到文件改动");
|
|
|
|
|
|
// return;
|
|
|
|
|
|
//}
|
|
|
|
|
|
// 初始化数据
|
|
|
|
|
|
updateName = dir_name + "_" + dir_cdn_setting + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss");
|
|
|
|
|
|
changeFileName = updateName.Replace("/", "$");
|
|
|
|
|
|
logName = changeFileName + "_UpLoad";
|
|
|
|
|
|
tagName = "hotfix/" + dir_name + "/" + dir_cdn_setting + "/" + local_version.version;
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("正在获取数据:", updateName, 0f);
|
|
|
|
|
|
log.Add("热更文件版本:" + updateName);
|
|
|
|
|
|
log.Add("热更版本号:" + local_version.version);
|
|
|
|
|
|
log.Add("热更大小:" + local_cdn_size);
|
|
|
|
|
|
// copy unity3d
|
|
|
|
|
|
log.Add("热更文件:");
|
|
|
|
|
|
List<string> changeFile = new List<string>();
|
|
|
|
|
|
foreach (ResourceFile rf in local_cdn_list)
|
|
|
|
|
|
{
|
|
|
|
|
|
changeFile.Add(rf.fileName);
|
|
|
|
|
|
log.Add(rf.fileName);
|
|
|
|
|
|
}
|
|
|
|
|
|
changeFile.Add(UpdateConfigs.FILES);
|
|
|
|
|
|
log.Add(UpdateConfigs.FILES);
|
|
|
|
|
|
// write ChangeList
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("正在生成文件变化列表", changeFileName, 1f);
|
|
|
|
|
|
HotFixTool.WriteLog(logPath, changeFileName, changeFile.ToArray());
|
|
|
|
|
|
// upload to cdn
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("正在上传热更文件", changeFileName, 1f);
|
|
|
|
|
|
|
|
|
|
|
|
string cdnType = GetSettingConfig("cdn_type");
|
|
|
|
|
|
if (cdnType == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UnityEngine.Debug.LogError("CDN配置错误");
|
|
|
|
|
|
EditorUtility.ClearProgressBar();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
log.Add("CDN TYPE: " + cdnType);
|
|
|
|
|
|
string toolsDir = HotfixWindow._HotFixProjectPath + "/Tools/" + cdnType;
|
|
|
|
|
|
log.Add("TOOLS DIR: " + toolsDir);
|
|
|
|
|
|
string command = string.Format("python UpLoad.py {0} {1} {2}>>{3}", HotfixWindow._HotFixProjectPath + "/Root/" + dir_name, dir_cdn_setting, changeFileName, logPath + logName + ".log");
|
|
|
|
|
|
log.Add("UPLOAD COMMAND: " + command);
|
|
|
|
|
|
ProcessUtil.ProcessCommand(toolsDir, command);
|
|
|
|
|
|
string flushCommand = string.Format("python Flush.py {0}>>{1}", cdn_version.resUrl, logPath + logName + ".log");
|
|
|
|
|
|
log.Add("Flush COMMAND: " + flushCommand);
|
|
|
|
|
|
ProcessUtil.ProcessCommand(toolsDir, flushCommand);
|
|
|
|
|
|
// write log
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("正在生成Log文件:", logName, 1f);
|
|
|
|
|
|
HotFixTool.WriteLog(logPath, logName, log.ToArray());
|
|
|
|
|
|
// git commit
|
|
|
|
|
|
string commitName = desc + "更新:" + updateName;
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("正在提交到GIT:", commitName, 1f);
|
|
|
|
|
|
ProcessUtil.ProcessCommand(path_cdn_setting, "git add .");
|
|
|
|
|
|
ProcessUtil.ProcessCommand(path_cdn_setting, "git commit -m " + commitName);
|
|
|
|
|
|
ProcessUtil.ProcessCommand(path_cdn_setting, "git push");
|
|
|
|
|
|
// git tag
|
|
|
|
|
|
string dir = Application.dataPath.Replace("/Assets", "");
|
|
|
|
|
|
ProcessUtil.ProcessCommand(dir, string.Format("git tag -a {0} -m {1}", tagName, commitName));
|
|
|
|
|
|
ProcessUtil.ProcessCommand(dir, "git push origin --tags");
|
|
|
|
|
|
UnityEngine.Debug.Log("更新完成,游戏工程标签为:" + tagName + ",热更工程提交:" + commitName);
|
|
|
|
|
|
|
|
|
|
|
|
EditorUtility.ClearProgressBar();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-31 11:24:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//看热更大小
|
|
|
|
|
|
public class HotfixWindow : EditorWindow
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
static string[][] _SettingConfig = new string[][]{
|
2021-06-11 18:02:42 +08:00
|
|
|
|
|
2021-05-31 11:24:20 +08:00
|
|
|
|
new string[]{ "C轮测试v2", "mht_china/local", "cdn_v2", "china/dev-c" },
|
2021-06-11 13:02:12 +08:00
|
|
|
|
new string[]{ "C轮测试v3", "mht_china/local", "cdn_v3", "china/dev-c" },
|
2021-06-11 18:02:42 +08:00
|
|
|
|
|
|
|
|
|
|
new string[]{ "灵动-专服-测试", "mht_china/zf", "cdn_mht_zf_test", "china/zf_test" },
|
|
|
|
|
|
new string[]{ "灵动-专服", "mht_china/zf", "cdn_mht_zf_release", "china/zf_test" },
|
|
|
|
|
|
new string[]{ "草花", "mht_china/zf", "cdn_caohua", "china/zf_test" },
|
2021-06-11 13:02:12 +08:00
|
|
|
|
new string[]{ "喜扑", "mht_china/zf", "cdn_xipu", "china/zf_test" },
|
2021-06-15 14:46:30 +08:00
|
|
|
|
|
|
|
|
|
|
new string[]{ "先遣-内网", "mht_china/local", "local12_cn_local", "china/local" },
|
|
|
|
|
|
new string[]{ "先遣-测试", "mht_china/xq", "cdn_xq_test", "china/test" },
|
|
|
|
|
|
new string[]{ "先遣-正式", "mht_china/xq", "cdn_xq_release", "china/test" },
|
2021-06-17 10:13:51 +08:00
|
|
|
|
|
2021-05-31 11:24:20 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static Dictionary<string, HotFixConfig> _HotFixConfigDic = new Dictionary<string, HotFixConfig>();
|
|
|
|
|
|
static string benchName = "";
|
|
|
|
|
|
public static string _HotFixProjectPath;
|
2021-06-24 13:54:48 +08:00
|
|
|
|
static string _Password = "";
|
2021-06-07 10:39:27 +08:00
|
|
|
|
static bool _IsUpdateCDN = false;
|
|
|
|
|
|
static bool _IsGitPull = false;
|
2021-05-31 11:24:20 +08:00
|
|
|
|
|
|
|
|
|
|
[MenuItem("Build/Hotfix")]
|
|
|
|
|
|
static void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
benchName = GitUtil.GetCurBenchName();
|
|
|
|
|
|
UnityEngine.Debug.Log("当前分支:" + benchName);
|
|
|
|
|
|
_HotFixProjectPath = EditorPrefs.GetString("_HotFixProjectPath", "");
|
2021-06-07 10:39:27 +08:00
|
|
|
|
if (!_IsGitPull && _HotFixProjectPath != "")
|
|
|
|
|
|
{
|
|
|
|
|
|
ABGitPull();
|
|
|
|
|
|
}
|
2021-05-31 11:24:20 +08:00
|
|
|
|
InitData();
|
|
|
|
|
|
InitStyle();
|
|
|
|
|
|
// Get existing open window or if none, make a new one:
|
|
|
|
|
|
HotfixWindow window = (HotfixWindow)EditorWindow.GetWindow(typeof(HotfixWindow));
|
2021-06-07 10:39:27 +08:00
|
|
|
|
window.titleContent = new GUIContent("热更新");
|
2021-05-31 11:24:20 +08:00
|
|
|
|
window.Show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void InitData()
|
|
|
|
|
|
{
|
2021-06-07 10:39:27 +08:00
|
|
|
|
_IsGitPull = false;
|
2021-05-31 11:24:20 +08:00
|
|
|
|
_HotFixConfigDic.Clear();
|
|
|
|
|
|
foreach (string[] sc in _SettingConfig)
|
|
|
|
|
|
{
|
|
|
|
|
|
string desc = sc[0];
|
|
|
|
|
|
string folder = sc[1];
|
|
|
|
|
|
string setting = sc[2];
|
|
|
|
|
|
string bench = sc[3];
|
|
|
|
|
|
if (bench.Equals(benchName))
|
|
|
|
|
|
{
|
|
|
|
|
|
HotFixConfig hfc;
|
|
|
|
|
|
_HotFixConfigDic.TryGetValue(folder, out hfc);
|
|
|
|
|
|
if (hfc == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
hfc = new HotFixConfig(folder);
|
|
|
|
|
|
_HotFixConfigDic.Add(folder, hfc);
|
|
|
|
|
|
}
|
|
|
|
|
|
hfc.AddSetting(desc, folder, setting);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 自定义style
|
2021-06-07 10:39:27 +08:00
|
|
|
|
static GUIStyle F_B_30 = new GUIStyle();
|
|
|
|
|
|
static GUIStyle F_25 = new GUIStyle();
|
|
|
|
|
|
static GUIStyle L_PL_50 = new GUIStyle();
|
2021-05-31 11:24:20 +08:00
|
|
|
|
static void InitStyle()
|
|
|
|
|
|
{
|
2021-06-07 10:39:27 +08:00
|
|
|
|
F_B_30.fontSize = 30;
|
|
|
|
|
|
F_B_30.fontStyle = FontStyle.Bold;
|
2021-05-31 11:24:20 +08:00
|
|
|
|
|
2021-06-07 10:39:27 +08:00
|
|
|
|
F_25.fontSize = 25;
|
|
|
|
|
|
L_PL_50.padding.left = 50;
|
2021-05-31 11:24:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnGUI()
|
|
|
|
|
|
{
|
2021-06-07 10:39:27 +08:00
|
|
|
|
if (AppConst.PlatformPath != "Android" && AppConst.PlatformPath != "IOS")
|
|
|
|
|
|
{
|
|
|
|
|
|
EditorGUILayout.LabelField("<color=red>请先切换到Android或者IOS平台</color>", F_B_30);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_Password = EditorGUILayout.PasswordField("请输入密码:", _Password);
|
|
|
|
|
|
if (_Password != "tcx123")
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2021-05-31 11:24:20 +08:00
|
|
|
|
EditorGUILayout.BeginVertical();
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.Space();
|
2021-06-07 10:39:27 +08:00
|
|
|
|
EditorGUILayout.LabelField("当前工程GIT分支:" + benchName);
|
2021-05-31 11:24:20 +08:00
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
|
|
|
_HotFixProjectPath = EditorGUILayout.TextField("热更GIT工程地址:", _HotFixProjectPath);
|
|
|
|
|
|
if (GUILayout.Button("Browse", GUILayout.ExpandWidth(false)))
|
|
|
|
|
|
{
|
|
|
|
|
|
_HotFixProjectPath = EditorUtility.OpenFolderPanel("Resource path", _HotFixProjectPath, _HotFixProjectPath);
|
|
|
|
|
|
EditorPrefs.SetString("_HotFixProjectPath", _HotFixProjectPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
EditorGUILayout.EndHorizontal();
|
2021-06-07 10:39:27 +08:00
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
_IsUpdateCDN = EditorGUILayout.ToggleLeft("是否显示CDN更新选项", _IsUpdateCDN);
|
2021-05-31 11:24:20 +08:00
|
|
|
|
|
2021-06-07 10:39:27 +08:00
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.LabelField("请选择要更新的GIT路径:");
|
|
|
|
|
|
foreach (string k in _HotFixConfigDic.Keys)// i = 0; i < _CurConfig.Length; i++)
|
2021-05-31 11:24:20 +08:00
|
|
|
|
{
|
|
|
|
|
|
HotFixConfig _CurConfig = _HotFixConfigDic[k];
|
|
|
|
|
|
|
2021-06-07 10:39:27 +08:00
|
|
|
|
_CurConfig.isChoose = EditorGUILayout.ToggleLeft("<color=yellow>" + _CurConfig.desc + "</color>", _CurConfig.isChoose, F_B_30, GUILayout.Height(40));
|
2021-05-31 11:24:20 +08:00
|
|
|
|
if (_CurConfig.isChoose)
|
|
|
|
|
|
{
|
2021-06-07 10:39:27 +08:00
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
|
|
|
EditorGUILayout.LabelField("工程到Git:" + _CurConfig.project_local_size.ToString("0.00") + "M");
|
2021-05-31 11:24:20 +08:00
|
|
|
|
if (!_CurConfig.isCalSize)
|
|
|
|
|
|
{
|
|
|
|
|
|
_CurConfig.CalHotFixSize();
|
|
|
|
|
|
}
|
2021-06-10 10:32:10 +08:00
|
|
|
|
if (GUILayout.Button("刷新", GUILayout.Height(20f)))
|
|
|
|
|
|
{
|
|
|
|
|
|
_CurConfig.CalHotFixSize();
|
|
|
|
|
|
}
|
2021-06-07 10:39:27 +08:00
|
|
|
|
if (GUILayout.Button("更新到GIT", GUILayout.Height(20f)))
|
2021-05-31 11:24:20 +08:00
|
|
|
|
{
|
2021-06-18 16:03:27 +08:00
|
|
|
|
string title = "是否要将工程热更文件同步到GIT: " + _CurConfig.desc;
|
|
|
|
|
|
string content = string.Format("更新大小:{0}", HotFixTool.GetDiffSize(_CurConfig.project_local_list).ToString("0.00") + "M");
|
|
|
|
|
|
HotfixConfimWindow.Create(title, content, _CurConfig.project_local_list, () =>
|
2021-05-31 11:24:20 +08:00
|
|
|
|
{
|
2021-06-07 10:39:27 +08:00
|
|
|
|
UpdateUnity3dToGit(_CurConfig);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
|
|
if (_IsUpdateCDN)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (HotFixSetting hfs in _CurConfig.hotFixSettings)// i = 0; i < _CurConfig.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
EditorGUILayout.BeginVertical(L_PL_50);
|
|
|
|
|
|
hfs.isChoose = EditorGUILayout.ToggleLeft("<color=green>" + hfs.desc + "</color>", hfs.isChoose, F_25, GUILayout.Height(30));
|
|
|
|
|
|
if (hfs.isChoose)
|
2021-05-31 11:24:20 +08:00
|
|
|
|
{
|
2021-06-07 10:39:27 +08:00
|
|
|
|
// 自动计算一遍大小
|
|
|
|
|
|
if (!hfs.isCalSize)
|
|
|
|
|
|
{
|
|
|
|
|
|
hfs.CalHotFixSize();
|
|
|
|
|
|
}
|
|
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
|
|
|
EditorGUILayout.BeginVertical();
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.LabelField("CDN当前版本号:" + (hfs.cdn_version == null ? "" : hfs.cdn_version.version));
|
|
|
|
|
|
EditorGUILayout.LabelField("GIT到CDN:" + hfs.local_cdn_size.ToString("0.00") + "M");
|
|
|
|
|
|
EditorGUILayout.EndVertical();
|
|
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("编辑Setting", GUILayout.Height(30f), GUILayout.Width(100f)))
|
|
|
|
|
|
{
|
|
|
|
|
|
string tpath = hfs.path_cdn_setting + "setting.txt";
|
|
|
|
|
|
ProcessUtil.OpenText(tpath);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (GUILayout.Button("编辑Config", GUILayout.Height(30f), GUILayout.Width(100f)))
|
|
|
|
|
|
{
|
|
|
|
|
|
string tpath = hfs.path_cdn_setting + AppConst.GameConfigFile;
|
|
|
|
|
|
ProcessUtil.OpenText(tpath);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (GUILayout.Button("编辑Version", GUILayout.Height(30f), GUILayout.Width(100f)))
|
|
|
|
|
|
{
|
|
|
|
|
|
string tpath = hfs.path_cdn_setting + AppConst.GameVersionFile;
|
|
|
|
|
|
ProcessUtil.OpenText(tpath);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (GUILayout.Button("刷新", GUILayout.Height(30f), GUILayout.Width(100f)))
|
|
|
|
|
|
{
|
|
|
|
|
|
hfs.CalHotFixSize();
|
|
|
|
|
|
}
|
2021-06-11 12:46:14 +08:00
|
|
|
|
if (GUILayout.Button("更新", GUILayout.Height(30f), GUILayout.Width(100f)))
|
|
|
|
|
|
{
|
2021-06-18 16:03:27 +08:00
|
|
|
|
//重新加载本地version
|
|
|
|
|
|
hfs.LoadLocalVersion();
|
|
|
|
|
|
string title = "是否要热更: " + hfs.desc;
|
|
|
|
|
|
string content = string.Format("更新大小:{0},CDN当前版本:{1},更新后版本{2}", HotFixTool.GetDiffSize(hfs.local_cdn_list).ToString("0.00") + "M", hfs.cdn_version.version, hfs.local_version.version);
|
|
|
|
|
|
HotfixConfimWindow.Create(title, content, hfs.local_cdn_list, () =>
|
2021-06-11 12:46:14 +08:00
|
|
|
|
{
|
2021-06-18 16:03:27 +08:00
|
|
|
|
hfs.DOUpload();
|
2021-06-11 12:46:14 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-06-07 10:39:27 +08:00
|
|
|
|
EditorGUILayout.EndHorizontal();
|
2021-05-31 11:24:20 +08:00
|
|
|
|
}
|
2021-06-07 10:39:27 +08:00
|
|
|
|
EditorGUILayout.EndVertical();
|
2021-05-31 11:24:20 +08:00
|
|
|
|
}
|
2021-06-07 10:39:27 +08:00
|
|
|
|
|
2021-05-31 11:24:20 +08:00
|
|
|
|
}
|
2021-06-07 10:39:27 +08:00
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
EditorGUILayout.Space();
|
2021-05-31 11:24:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.EndVertical();
|
|
|
|
|
|
}
|
2021-06-07 10:39:27 +08:00
|
|
|
|
|
|
|
|
|
|
// 拉取git工程
|
|
|
|
|
|
private static void ABGitPull()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!_IsGitPull)
|
|
|
|
|
|
{
|
|
|
|
|
|
ProcessUtil.ProcessCommand(_HotFixProjectPath, "git pull", true);
|
|
|
|
|
|
|
|
|
|
|
|
_IsGitPull = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//同步工程中的热更文件到git
|
|
|
|
|
|
private static void UpdateUnity3dToGit(HotFixConfig hfc)
|
|
|
|
|
|
{
|
|
|
|
|
|
string updateName;
|
|
|
|
|
|
List<ResourceFile> updateList;
|
|
|
|
|
|
List<string> log = new List<string>();
|
|
|
|
|
|
updateList = hfc.project_local_list;
|
|
|
|
|
|
if (updateList.Count <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
UnityEngine.Debug.Log("未检测到文件改动");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2021-06-10 10:32:10 +08:00
|
|
|
|
// 初始化数据
|
|
|
|
|
|
updateName = benchName + "_" + GitUtil.GetCurCommitHash() + "_"+DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss");
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("正在获取数据:", updateName, 0f);
|
|
|
|
|
|
log.Add("热更文件版本:" + updateName);
|
|
|
|
|
|
log.Add("热更文件的工程对应的提交信息:" );
|
|
|
|
|
|
string[] infos = GitUtil.GetCurCommitSimpleInfo();
|
|
|
|
|
|
foreach(string info in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.Add(info);
|
|
|
|
|
|
}
|
|
|
|
|
|
log.Add("热更大小:"+hfc.project_local_size);
|
2021-06-07 10:39:27 +08:00
|
|
|
|
// copy unity3d
|
|
|
|
|
|
log.Add("热更文件:");
|
|
|
|
|
|
string fromPath = hfc.project_files_path;
|
|
|
|
|
|
string toPath = hfc.local_files_path;
|
2021-06-10 10:32:10 +08:00
|
|
|
|
int i = 0;
|
2021-06-07 10:39:27 +08:00
|
|
|
|
foreach (ResourceFile rf in updateList)
|
|
|
|
|
|
{
|
2021-06-10 10:32:10 +08:00
|
|
|
|
EditorUtility.DisplayProgressBar("正在复制文件:" + toPath, rf.fileName, (float)i/updateList.Count);
|
2021-06-07 10:39:27 +08:00
|
|
|
|
File.Copy(fromPath + rf.fileName, toPath + rf.fileName, true);
|
|
|
|
|
|
log.Add(rf.fileName);
|
|
|
|
|
|
}
|
2021-06-11 13:16:55 +08:00
|
|
|
|
File.Copy(fromPath + UpdateConfigs.FILES, toPath + UpdateConfigs.FILES, true);
|
|
|
|
|
|
log.Add(UpdateConfigs.FILES);
|
2021-06-10 10:32:10 +08:00
|
|
|
|
// write logf
|
|
|
|
|
|
string logName = updateName.Replace("/", "$");
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("正在生成Log文件:", logName, 1f);
|
|
|
|
|
|
WriteLog(toPath+"/_log", logName, log.ToArray());
|
2021-06-07 10:39:27 +08:00
|
|
|
|
// git commit
|
2021-06-10 10:32:10 +08:00
|
|
|
|
string commitName = hfc.dir_name + "热更文件更新:" + updateName;
|
|
|
|
|
|
EditorUtility.DisplayProgressBar("正在提交到GIT:", commitName, 1f);
|
|
|
|
|
|
ProcessUtil.ProcessCommand(toPath, "git add .");
|
|
|
|
|
|
ProcessUtil.ProcessCommand(toPath, "git commit -m " + commitName);
|
2021-06-15 15:23:05 +08:00
|
|
|
|
ProcessUtil.ProcessCommand(toPath, "git push");
|
2021-06-10 10:32:10 +08:00
|
|
|
|
EditorUtility.ClearProgressBar();
|
|
|
|
|
|
}
|
2021-06-07 10:39:27 +08:00
|
|
|
|
|
2021-06-11 12:46:14 +08:00
|
|
|
|
//同步工程中的热更文件到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);
|
|
|
|
|
|
}
|
2021-06-11 13:16:55 +08:00
|
|
|
|
changeFile.Add(UpdateConfigs.FILES);
|
|
|
|
|
|
log.Add(UpdateConfigs.FILES);
|
2021-06-11 12:46:14 +08:00
|
|
|
|
// 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"];
|
|
|
|
|
|
log.Add("TOOLS DIR: " + toolsDir);
|
2021-06-15 14:46:30 +08:00
|
|
|
|
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");
|
2021-06-11 12:46:14 +08:00
|
|
|
|
log.Add("UPLOAD COMMAND: " + command);
|
|
|
|
|
|
ProcessUtil.ProcessCommand(toolsDir, command);
|
2021-06-15 14:46:30 +08:00
|
|
|
|
string flushCommand = string.Format("python Flush.py {0}>>{1}", hfs.cdn_version.resUrl, hfs.path_cdn_setting + "__HotFixLog/" + logName + ".log");
|
|
|
|
|
|
log.Add("Flush COMMAND: " + flushCommand);
|
|
|
|
|
|
ProcessUtil.ProcessCommand(toolsDir, flushCommand);
|
2021-06-11 12:46:14 +08:00
|
|
|
|
// 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);
|
2021-06-15 15:23:05 +08:00
|
|
|
|
ProcessUtil.ProcessCommand(hfs.path_cdn_setting, "git push");
|
2021-06-11 12:46:14 +08:00
|
|
|
|
EditorUtility.ClearProgressBar();
|
|
|
|
|
|
}
|
2021-06-17 10:13:51 +08:00
|
|
|
|
|
2021-06-10 10:32:10 +08:00
|
|
|
|
private static void WriteLog(string path, string name, string[] contents)
|
|
|
|
|
|
{
|
2021-06-07 10:39:27 +08:00
|
|
|
|
|
2021-06-10 10:32:10 +08:00
|
|
|
|
UnityEngine.Debug.Log("创建log文件");
|
|
|
|
|
|
UnityEngine.Debug.Log(path);
|
|
|
|
|
|
UnityEngine.Debug.Log(name);
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
|
}
|
|
|
|
|
|
string filePath = Path.Combine(path, name) + ".log";
|
|
|
|
|
|
//if (!File.Exists(filePath))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// File.Create(filePath).Close();
|
|
|
|
|
|
//}
|
|
|
|
|
|
File.WriteAllLines(filePath, contents);
|
2021-06-07 10:39:27 +08:00
|
|
|
|
}
|
2021-06-10 10:32:10 +08:00
|
|
|
|
|
2021-05-31 11:24:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-06-07 10:39:27 +08:00
|
|
|
|
//看热更大小
|
|
|
|
|
|
public class HotfixConfimWindow : EditorWindow
|
|
|
|
|
|
{
|
2021-06-18 16:03:27 +08:00
|
|
|
|
string title;
|
2021-06-07 10:39:27 +08:00
|
|
|
|
string content;
|
|
|
|
|
|
List<ResourceFile> diffList;
|
|
|
|
|
|
Action a;
|
|
|
|
|
|
Vector2 _scp = Vector2.zero;
|
2021-06-18 16:03:27 +08:00
|
|
|
|
public static void Create(string title, string content, List<ResourceFile> diffList, Action a)
|
2021-06-07 10:39:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
HotfixConfimWindow window = (HotfixConfimWindow)EditorWindow.GetWindow(typeof(HotfixConfimWindow), true, "提示", true);
|
2021-06-18 16:03:27 +08:00
|
|
|
|
window.SetContent(title, content, diffList, a);
|
2021-06-07 10:39:27 +08:00
|
|
|
|
window.ShowAuxWindow();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-18 16:03:27 +08:00
|
|
|
|
public void SetContent(string _title, string _content, List<ResourceFile> _diffList, Action _a)
|
2021-06-07 10:39:27 +08:00
|
|
|
|
{
|
2021-06-18 16:03:27 +08:00
|
|
|
|
title = _title;
|
2021-06-07 10:39:27 +08:00
|
|
|
|
content = _content;
|
|
|
|
|
|
diffList = _diffList;
|
|
|
|
|
|
a = _a;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnGUI()
|
|
|
|
|
|
{
|
|
|
|
|
|
EditorGUILayout.BeginVertical();
|
2021-06-18 16:03:27 +08:00
|
|
|
|
EditorGUILayout.LabelField(title);
|
2021-06-07 10:39:27 +08:00
|
|
|
|
_scp = EditorGUILayout.BeginScrollView(_scp);
|
|
|
|
|
|
foreach(ResourceFile rf in diffList)
|
|
|
|
|
|
{
|
|
|
|
|
|
EditorGUILayout.LabelField(rf.fileName);
|
|
|
|
|
|
}
|
2021-06-18 16:03:27 +08:00
|
|
|
|
EditorGUILayout.LabelField("files.unity3d");
|
|
|
|
|
|
EditorGUILayout.LabelField(AppConst.GameConfigFile);
|
|
|
|
|
|
EditorGUILayout.LabelField(AppConst.GameVersionFile);
|
2021-06-07 10:39:27 +08:00
|
|
|
|
EditorGUILayout.EndScrollView();
|
2021-06-18 16:03:27 +08:00
|
|
|
|
EditorGUILayout.LabelField(content);//"更新大小:" + HotFixTool.GetDiffSize(diffList).ToString("0.00") + "M");
|
2021-06-07 10:39:27 +08:00
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
|
|
|
if (GUILayout.Button("取消")){
|
|
|
|
|
|
Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (GUILayout.Button("确定"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (a!= null) a();
|
|
|
|
|
|
}
|
|
|
|
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
|
|
EditorGUILayout.EndVertical();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|