添加整理资源
parent
eca086eabc
commit
bdba95c160
|
|
@ -961,7 +961,7 @@ namespace Assets.Scripts.Editor.LanguageTool
|
||||||
fileName = Path.GetDirectoryName(files[j]) + "/" + fileName + artTab + _ex;
|
fileName = Path.GetDirectoryName(files[j]) + "/" + fileName + artTab + _ex;
|
||||||
Debug.Log("文件名:" + fileName);
|
Debug.Log("文件名:" + fileName);
|
||||||
EditorUtility.DisplayProgressBar("遍历图片资源目录", string.Format("正在检索数据:{0}/{1}", i, dirs.Count), (float)i / dirs.Count);
|
EditorUtility.DisplayProgressBar("遍历图片资源目录", string.Format("正在检索数据:{0}/{1}", i, dirs.Count), (float)i / dirs.Count);
|
||||||
File.Move(files[j], fileName);
|
AssetDatabase.MoveAsset(files[j], fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EditorUtility.ClearProgressBar();
|
EditorUtility.ClearProgressBar();
|
||||||
|
|
@ -1151,5 +1151,90 @@ namespace Assets.Scripts.Editor.LanguageTool
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
}
|
}
|
||||||
|
[MenuItem("LanguageTool/artFont/资源分类")]
|
||||||
|
private static void FileClassFied()
|
||||||
|
{
|
||||||
|
string dirPath = Environment.CurrentDirectory + "\\Assets\\ManagedResources";
|
||||||
|
string enPath = dirPath + "/ArtFont_en/";
|
||||||
|
string viPath = dirPath + "/ArtFont_vi/";
|
||||||
|
List<string> dirs = new List<string>(Directory.GetDirectories(dirPath, "ArtFont", SearchOption.AllDirectories));
|
||||||
|
for (int i = 0; i < dirs.Count; i++)
|
||||||
|
{
|
||||||
|
EditorUtility.DisplayProgressBar("创建图片资源目录",
|
||||||
|
string.Format("{0}:{1}/{2}", dirs[i], i, dirs.Count), (float)i / dirs.Count);
|
||||||
|
string dirName = GetDirName(dirs[i]);
|
||||||
|
if (string.IsNullOrEmpty(dirName))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!Directory.Exists(enPath + dirName))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(enPath + dirName);
|
||||||
|
}
|
||||||
|
if (!Directory.Exists(viPath + dirName))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(viPath + dirName);
|
||||||
|
}
|
||||||
|
string[] zhFiles = Directory.GetFiles(dirs[i]);
|
||||||
|
for (int j = 0; j < zhFiles.Length; j++)
|
||||||
|
{
|
||||||
|
string fileName = Path.GetFileNameWithoutExtension(zhFiles[j]);
|
||||||
|
string _ex = Path.GetExtension(zhFiles[j]);
|
||||||
|
if (_ex == ".meta")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (fileName.EndsWith("_zh"))
|
||||||
|
{
|
||||||
|
fileName = fileName.Substring(0, fileName.Length - 3);
|
||||||
|
}
|
||||||
|
EditorUtility.DisplayProgressBar("整理图片",
|
||||||
|
string.Format("{0}:{1}/{2}", fileName, j, zhFiles.Length), (float)j / zhFiles.Length);
|
||||||
|
string enFileName = fileName + "_en" + _ex;
|
||||||
|
string viFileName = fileName + "_vi" + _ex;
|
||||||
|
if (File.Exists(enPath + enFileName))
|
||||||
|
{
|
||||||
|
SortingImage(enFileName, "Assets/ManagedResources/ArtFont_en/", "Assets/ManagedResources/ArtFont_en/" + dirName);
|
||||||
|
}
|
||||||
|
if (File.Exists(viPath + viFileName))
|
||||||
|
{
|
||||||
|
SortingImage(viFileName, "Assets/ManagedResources/ArtFont_vi/", "Assets/ManagedResources/ArtFont_vi/" + dirName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
EditorUtility.ClearProgressBar();
|
||||||
|
}
|
||||||
|
private static string GetDirName(string str)
|
||||||
|
{
|
||||||
|
string[] strs = str.Split('\\');
|
||||||
|
bool isAdd = false;
|
||||||
|
string dirName = "";
|
||||||
|
for (int i = 0; i < strs.Length; i++)
|
||||||
|
{
|
||||||
|
if (strs[i] == "ManagedResources")
|
||||||
|
{
|
||||||
|
isAdd = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (isAdd)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(dirName))
|
||||||
|
{
|
||||||
|
dirName = strs[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dirName = dirName + "#" + strs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dirName;
|
||||||
|
}
|
||||||
|
private static void SortingImage(string fileName,string oldPath,string newPath)
|
||||||
|
{
|
||||||
|
AssetDatabase.MoveAsset(oldPath + fileName, newPath + "/" + fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue