|
@@ -236,12 +236,12 @@ namespace GFGEditor
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- public static void DeleteUnnecessaryImage(string targetPath, string saveName = "")
|
|
|
|
|
|
+ public static void DeleteUnnecessaryImage(string targetPath, string[] saveNames)
|
|
{
|
|
{
|
|
- if (saveName != "")
|
|
|
|
|
|
+ if (saveNames.Length > 0)
|
|
{
|
|
{
|
|
- DeleteUnnecessaryImageRes(targetPath, saveName);
|
|
|
|
- DeleteUnnecessaryImageMD5(saveName);
|
|
|
|
|
|
+ DeleteUnnecessaryImageMD5(saveNames);
|
|
|
|
+ DeleteUnnecessaryImageRes(targetPath, saveNames);
|
|
}
|
|
}
|
|
|
|
|
|
if (targetPath == ImportArtResTool.DressUpTargetPath)
|
|
if (targetPath == ImportArtResTool.DressUpTargetPath)
|
|
@@ -253,26 +253,30 @@ namespace GFGEditor
|
|
}
|
|
}
|
|
|
|
|
|
//清除无资源的Md5数据
|
|
//清除无资源的Md5数据
|
|
- public static void DeleteUnnecessaryImageMD5(string saveName)
|
|
|
|
|
|
+ public static void DeleteUnnecessaryImageMD5(string[] saveNames)
|
|
{
|
|
{
|
|
- List<string> rKeys = new List<string>();
|
|
|
|
- Dictionary<string, string> sourceResMD5 = new Dictionary<string, string>();
|
|
|
|
- sourceResMD5 = ImagesClip.ReadSourceImagesMD5(saveName);
|
|
|
|
- ICollection keys = sourceResMD5.Keys;
|
|
|
|
- foreach (string key in keys)
|
|
|
|
|
|
+ for (int j = 0; j < saveNames.Length; j++)
|
|
{
|
|
{
|
|
- if (!File.Exists(key))
|
|
|
|
|
|
+ string saveName = saveNames[j];
|
|
|
|
+ List<string> rKeys = new List<string>();
|
|
|
|
+ Dictionary<string, string> sourceResMD5 = new Dictionary<string, string>();
|
|
|
|
+ sourceResMD5 = ImagesClip.ReadSourceImagesMD5(saveName);
|
|
|
|
+ ICollection keys = sourceResMD5.Keys;
|
|
|
|
+ foreach (string key in keys)
|
|
{
|
|
{
|
|
- rKeys.Add(key);
|
|
|
|
|
|
+ if (!File.Exists(key))
|
|
|
|
+ {
|
|
|
|
+ rKeys.Add(key);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ for (int i = 0; i < rKeys.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ sourceResMD5.Remove(rKeys[i]);
|
|
|
|
+ }
|
|
|
|
+ ImagesClip.WriteSourceImagesMD5(sourceResMD5, saveName);
|
|
}
|
|
}
|
|
- for (int i = 0; i < rKeys.Count; i++)
|
|
|
|
- {
|
|
|
|
- sourceResMD5.Remove(rKeys[i]);
|
|
|
|
- }
|
|
|
|
- ImagesClip.WriteSourceImagesMD5(sourceResMD5, saveName);
|
|
|
|
}
|
|
}
|
|
- public static void DeleteUnnecessaryImageRes(string targetPath, string saveName)
|
|
|
|
|
|
+ public static void DeleteUnnecessaryImageRes(string targetPath, string[] saveNames)
|
|
{
|
|
{
|
|
string[] includeExtensionNames = new string[] { ".png", ".jpg" };
|
|
string[] includeExtensionNames = new string[] { ".png", ".jpg" };
|
|
if (!Directory.Exists(targetPath))
|
|
if (!Directory.Exists(targetPath))
|
|
@@ -281,7 +285,7 @@ namespace GFGEditor
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var files = Directory.GetFiles(targetPath);
|
|
var files = Directory.GetFiles(targetPath);
|
|
- foreach (var file in files)
|
|
|
|
|
|
+ foreach (var file in files)//遍历项目中的所有资源
|
|
{
|
|
{
|
|
|
|
|
|
if (file.Trim() != file)
|
|
if (file.Trim() != file)
|
|
@@ -289,25 +293,32 @@ namespace GFGEditor
|
|
Debug.LogError($"请检查文件名 {file}");
|
|
Debug.LogError($"请检查文件名 {file}");
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
string fileName = Path.GetFileName(file);
|
|
string fileName = Path.GetFileName(file);
|
|
|
|
+ string extensionName = Path.GetExtension(file);
|
|
|
|
+ if (extensionName == ".meta" || extensionName == ".bytes") continue;
|
|
|
|
|
|
- Dictionary<string, string> sourceResMD5 = new Dictionary<string, string>();
|
|
|
|
- sourceResMD5 = ImagesClip.ReadSourceImagesMD5(saveName);
|
|
|
|
- ICollection keys = sourceResMD5.Keys;
|
|
|
|
- foreach (string key in keys)
|
|
|
|
|
|
+ bool has = false;
|
|
|
|
+ for (int i = 0; i < saveNames.Length; i++)
|
|
{
|
|
{
|
|
- if (!File.Exists(key))
|
|
|
|
|
|
+ string saveName = saveNames[i];
|
|
|
|
+ Dictionary<string, string> sourceResMD5 = new Dictionary<string, string>();
|
|
|
|
+ sourceResMD5 = ImagesClip.ReadSourceImagesMD5(saveName);
|
|
|
|
+ ICollection keys = sourceResMD5.Keys;
|
|
|
|
+ foreach (string key in keys)//遍历MD5中记录的所有正式资源路径
|
|
{
|
|
{
|
|
|
|
+ // if (!File.Exists(key))//记录的路径在正式资源里不存在
|
|
|
|
+ // {
|
|
string sourceName = Path.GetFileName(key);
|
|
string sourceName = Path.GetFileName(key);
|
|
|
|
|
|
- string targetFilePath = targetPath + fileName;
|
|
|
|
if (sourceName == fileName)
|
|
if (sourceName == fileName)
|
|
{
|
|
{
|
|
- File.Delete(targetFilePath);
|
|
|
|
|
|
+ has = true;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ if (!has) File.Delete(targetPath + fileName);
|
|
}
|
|
}
|
|
Debug.Log(targetPath + "清除完成!");
|
|
Debug.Log(targetPath + "清除完成!");
|
|
}
|
|
}
|