|
|
@@ -6,6 +6,8 @@ using Game.Config;
|
|
|
using System;
|
|
|
using System.Reflection;
|
|
|
using System.IO;
|
|
|
+using System.IO.Compression;
|
|
|
+
|
|
|
public class CheckHotUpdateRes : EditorWindow
|
|
|
{
|
|
|
|
|
|
@@ -37,16 +39,17 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
CheckHotUpdateRes window = GetWindow<CheckHotUpdateRes>("热更相关");
|
|
|
window.maxSize = new Vector2(800, 600);
|
|
|
window.minSize = new Vector2(600, 400);
|
|
|
-
|
|
|
- window.Show();
|
|
|
|
|
|
window.Init();
|
|
|
+ window.Show();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private string oldPath = "";
|
|
|
private string newPath = "";
|
|
|
|
|
|
private CheckResWindowInfo info;
|
|
|
+ private ResInfo curResInfo;
|
|
|
private List<VersionInfoData> needResList;
|
|
|
private GameDataFormatInfo downloadFormatInfo;
|
|
|
public void Init()
|
|
|
@@ -54,6 +57,11 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
string path = "Assets/Editor/AssetBundle/CheckHotResWindownInfo.asset";
|
|
|
//Debug.Log();
|
|
|
info = AssetDatabase.LoadAssetAtPath<CheckResWindowInfo>(path);
|
|
|
+ curResInfo = info.GetResInfo();
|
|
|
+ if (curResInfo == null)
|
|
|
+ {
|
|
|
+ curResInfo = new ResInfo();
|
|
|
+ }
|
|
|
#if UNITY_IOS
|
|
|
info.VersionFileName = "afivs";
|
|
|
info.mainfestFileName = "afimft";
|
|
|
@@ -67,9 +75,9 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
|
|
|
private void OnGUI()
|
|
|
{
|
|
|
- DrowSelectFolder("旧版本文件", "选择文件路径", "选择旧版本资源MD5文件路径", ref info.OldPath);
|
|
|
- DrowSelectFolder("新版本文件", "选择文件路径", "选择新版本资源MD5文件路径", ref info.NewPath);
|
|
|
- DrowSelectFolder("需跟新文件输出路径", "选择文件路径", "选择需跟新文件输出路径", ref info.OutputPath);
|
|
|
+ DrowSelectFolder("旧版本文件", "选择文件路径", "选择旧版本资源MD5文件路径", ref curResInfo.OldPath);
|
|
|
+ DrowSelectFolder("新版本文件", "选择文件路径", "选择新版本资源MD5文件路径", ref curResInfo.NewPath);
|
|
|
+ DrowSelectFolder("需跟新文件输出路径", "选择文件路径", "选择需跟新文件输出路径", ref curResInfo.OutputPath);
|
|
|
DrawInfo();
|
|
|
DrawCheckBtn();
|
|
|
|
|
|
@@ -106,6 +114,21 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
|
|
|
private void DrawInfo()
|
|
|
{
|
|
|
+ GUILayout.Box("", GUILayout.Width(790));
|
|
|
+ GUILayout.BeginHorizontal();
|
|
|
+ GUILayout.Label("平台", GUILayout.Width(65));
|
|
|
+ BuildTag tag = (BuildTag)EditorGUILayout.EnumPopup(info.buildTag, GUILayout.Width(100));
|
|
|
+ if (tag != info.buildTag)
|
|
|
+ {
|
|
|
+ info.buildTag = tag;
|
|
|
+ ResInfo ri = info.GetResInfo();
|
|
|
+ if (ri != null)
|
|
|
+ {
|
|
|
+ curResInfo = ri;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ GUILayout.EndHorizontal();
|
|
|
|
|
|
GUILayout.Box("", GUILayout.Width(790));
|
|
|
GUILayout.BeginHorizontal();
|
|
|
@@ -113,12 +136,12 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
GUILayout.Space(10);
|
|
|
GUILayout.Label("版本文件名:", GUILayout.Width(65));
|
|
|
GUILayout.Space(10);
|
|
|
- info.VersionFileName = GUILayout.TextField(info.VersionFileName, GUILayout.Width(160));
|
|
|
+ curResInfo.VersionFileName = GUILayout.TextField(curResInfo.VersionFileName, GUILayout.Width(160));
|
|
|
|
|
|
GUILayout.Space(60);
|
|
|
GUILayout.Label("版本文件信息文件名:", GUILayout.Width(120));
|
|
|
GUILayout.Space(10);
|
|
|
- info.mainfestFileName = GUILayout.TextField(info.mainfestFileName, GUILayout.Width(160));
|
|
|
+ curResInfo.mainfestFileName = GUILayout.TextField(curResInfo.mainfestFileName, GUILayout.Width(160));
|
|
|
|
|
|
|
|
|
GUILayout.EndHorizontal();
|
|
|
@@ -128,19 +151,19 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
GUILayout.Space(10);
|
|
|
GUILayout.Label("资源版本:", GUILayout.Width(65));
|
|
|
GUILayout.Space(10);
|
|
|
- info.ResVersion = GUILayout.TextField(info.ResVersion, GUILayout.Width(160));
|
|
|
+ curResInfo.ResVersion = GUILayout.TextField(curResInfo.ResVersion, GUILayout.Width(160));
|
|
|
GUILayout.Space(10);
|
|
|
if (GUILayout.Button("读取版本", GUILayout.Width(100)))
|
|
|
{
|
|
|
- info.ResVersion = File.ReadAllText($"{info.OldPath}/{info.VersionFileName}");
|
|
|
+ curResInfo.ResVersion = File.ReadAllText($"{curResInfo.OldPath}/{curResInfo.VersionFileName}");
|
|
|
}
|
|
|
GUILayout.Space(10);
|
|
|
|
|
|
if (GUILayout.Button("版本+1", GUILayout.Width(100)))
|
|
|
{
|
|
|
- VersionCode lVersionCode = info.ResVersion;
|
|
|
+ VersionCode lVersionCode = curResInfo.ResVersion;
|
|
|
lVersionCode.patch += 1;
|
|
|
- info.ResVersion = lVersionCode.ToString();
|
|
|
+ curResInfo.ResVersion = lVersionCode.ToString();
|
|
|
}
|
|
|
GUILayout.Space(10);
|
|
|
GUILayout.EndHorizontal();
|
|
|
@@ -148,7 +171,7 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
GUILayout.BeginHorizontal();
|
|
|
GUILayout.Label("语言:", GUILayout.Width(65));
|
|
|
GUILayout.Space(10);
|
|
|
- info.Language = (BuildLanguage)EditorGUILayout.EnumPopup(info.Language, GUILayout.Width(100));
|
|
|
+ curResInfo.Language = (BuildLanguage)EditorGUILayout.EnumPopup(curResInfo.Language, GUILayout.Width(100));
|
|
|
GUILayout.Space(10);
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
|
@@ -161,7 +184,7 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
GUILayout.Space(10);
|
|
|
if (GUILayout.Button("生成MD5资源版本文件"))
|
|
|
{
|
|
|
- BundleBuilderZ.CreateMD5File(info.ResVersion);
|
|
|
+ BundleBuilderZ.CreateMD5File(curResInfo.ResVersion);
|
|
|
}
|
|
|
|
|
|
GUILayout.Space(60);
|
|
|
@@ -188,12 +211,12 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
GUILayout.Box("", GUILayout.Width(790));
|
|
|
GUILayout.BeginHorizontal();
|
|
|
GUILayout.Space(60);
|
|
|
- info.IsIgnore =GUILayout.Toggle(info.IsIgnore, "是否开启忽略某些文件") ;
|
|
|
+ curResInfo.IsIgnore =GUILayout.Toggle(curResInfo.IsIgnore, "是否开启忽略某些文件") ;
|
|
|
GUILayout.EndHorizontal();
|
|
|
}
|
|
|
private List<VersionInfoData> SerizlizeResList(byte[] data)
|
|
|
{
|
|
|
- CsvReader csvReader = new CsvReader(info.mainfestFileName, data);
|
|
|
+ CsvReader csvReader = new CsvReader(curResInfo.mainfestFileName, data);
|
|
|
if (downloadFormatInfo == null)
|
|
|
{
|
|
|
downloadFormatInfo = new GameDataFormatInfo(csvReader.Fields(), csvReader.Types());
|
|
|
@@ -210,11 +233,11 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
private void CheckRes()
|
|
|
{
|
|
|
needResList.Clear();
|
|
|
- oldPath = $"{info.OldPath}/{ info.mainfestFileName}";
|
|
|
+ oldPath = $"{curResInfo.OldPath}/{ curResInfo.mainfestFileName}";
|
|
|
|
|
|
List<VersionInfoData> Oldlist = GetInfoDatas(oldPath);
|
|
|
|
|
|
- newPath = $"{info.NewPath}/{ info.mainfestFileName}";
|
|
|
+ newPath = $"{curResInfo.NewPath}/{ curResInfo.mainfestFileName}";
|
|
|
|
|
|
List<VersionInfoData> newlist = GetInfoDatas(newPath);
|
|
|
ChangeResMD5(newlist);
|
|
|
@@ -225,15 +248,15 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
for (int i = 0; i < size; i++)
|
|
|
{
|
|
|
|
|
|
- if (newlist[i].FullName == info.mainfestFileName || newlist[i].FullName == info.VersionFileName)
|
|
|
+ if (newlist[i].FullName == curResInfo.mainfestFileName || newlist[i].FullName == curResInfo.VersionFileName)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
bool isignore = false;
|
|
|
- if (info.IsIgnore)
|
|
|
+ if (curResInfo.IsIgnore)
|
|
|
{
|
|
|
- string igstr = info.IgnoreFiles.FindFirst(it => it == newlist[i].FullName);
|
|
|
+ string igstr = curResInfo.IgnoreFiles.FindFirst(it => it == newlist[i].FullName);
|
|
|
if (!string.IsNullOrEmpty(igstr))
|
|
|
{
|
|
|
isignore = true;
|
|
|
@@ -268,21 +291,33 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
csvWriter.Write();
|
|
|
|
|
|
CopyFile();
|
|
|
-
|
|
|
+ string FiletempPath = $"{curResInfo.OutputPath}/../ZipTempPath";
|
|
|
+ if(Directory.Exists(FiletempPath))
|
|
|
+ Directory.Delete(FiletempPath,true);
|
|
|
+ Directory.CreateDirectory(FiletempPath);
|
|
|
+ CopyFile(FiletempPath);
|
|
|
+ string zipName = $"{curResInfo.CN_Name}---{curResInfo.ResVersion}---{DateTime.Now.Month}.{DateTime.Now.Day}--1.zip";
|
|
|
+ ZipFile.CreateFromDirectory(FiletempPath,$"{curResInfo.OutputPath}/{zipName}");
|
|
|
+ Directory.Delete(FiletempPath,true);
|
|
|
needResList.Clear();
|
|
|
- Debug.Log($"资源检查完成 输出路径 : 【{info.OutputPath}】");
|
|
|
+ Debug.Log($"资源检查完成 输出路径 : 【{curResInfo.OutputPath}】");
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void CopyFile()
|
|
|
+ private void CopyFile(string outP = "")
|
|
|
{
|
|
|
if (needResList == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(outP))
|
|
|
+ {
|
|
|
+ outP = curResInfo.OutputPath;
|
|
|
+ }
|
|
|
int size = needResList.Count;
|
|
|
|
|
|
- string datapath = $"{info.NewPath}/";
|
|
|
+ string datapath = $"{curResInfo.NewPath}/";
|
|
|
|
|
|
for (int i = 0; i < size; i++)
|
|
|
{
|
|
|
@@ -292,15 +327,15 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
}
|
|
|
byte[] fdatas = File.ReadAllBytes(datapath + needResList[i].FullName);
|
|
|
|
|
|
- FileHelper.WirteToFile( $"{info.OutputPath}/{needResList[i].FullName}" ,fdatas);
|
|
|
+ FileHelper.WirteToFile( $"{outP}/{needResList[i].FullName}" ,fdatas);
|
|
|
|
|
|
}
|
|
|
|
|
|
- FileHelper.WirteStringToFile($"{info.OutputPath}/{info.VersionFileName}",info.ResVersion);
|
|
|
+ FileHelper.WirteStringToFile($"{outP}/{curResInfo.VersionFileName}",curResInfo.ResVersion);
|
|
|
|
|
|
- byte[] mdatas = File.ReadAllBytes(datapath + info.mainfestFileName);
|
|
|
+ byte[] mdatas = File.ReadAllBytes(datapath + curResInfo.mainfestFileName);
|
|
|
|
|
|
- FileHelper.WirteToFile($"{info.OutputPath}/{info.mainfestFileName}", mdatas);
|
|
|
+ FileHelper.WirteToFile($"{outP}/{curResInfo.mainfestFileName}", mdatas);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -329,7 +364,7 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
|
|
|
private void ChangeResMD5(List<VersionInfoData> datas)
|
|
|
{
|
|
|
- int[] ids = GenerateRandomArray(info.ChangeNum, 1, datas.Count);
|
|
|
+ int[] ids = GenerateRandomArray(curResInfo.ChangeNum, 1, datas.Count);
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ids.Length; i++)
|
|
|
@@ -375,17 +410,17 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
|
|
|
private void CopyFiles()
|
|
|
{
|
|
|
- string[] files1 = FileHelper.GetAllFileNmae(info.NewPath, "meta");
|
|
|
+ string[] files1 = FileHelper.GetAllFileNmae(curResInfo.NewPath, "meta");
|
|
|
|
|
|
int size = files1.Length;
|
|
|
|
|
|
- string datapath = $"{info.NewPath}/";
|
|
|
+ string datapath = $"{curResInfo.NewPath}/";
|
|
|
for (int i = 0; i < size; i++)
|
|
|
{
|
|
|
|
|
|
byte[] fdatas = File.ReadAllBytes(datapath + files1[i]);
|
|
|
|
|
|
- FileHelper.WirteToFile($"{info.OutputPath}/{files1[i]}", fdatas);
|
|
|
+ FileHelper.WirteToFile($"{curResInfo.OutputPath}/{files1[i]}", fdatas);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -394,6 +429,6 @@ public class CheckHotUpdateRes : EditorWindow
|
|
|
private void CopyTexture()
|
|
|
{
|
|
|
string datapath = $"{Application.dataPath}/Content/Icons/";
|
|
|
- FileHelper.CopyDir(datapath, info.OutputPath, "meta");
|
|
|
+ FileHelper.CopyDir(datapath, curResInfo.OutputPath, "meta");
|
|
|
}
|
|
|
}
|