资源导入工具修改提交

dev_chengFeng
jiaoyangna 2021-07-05 18:52:37 +08:00
parent d25b80dd1b
commit b36edb9ae9
1 changed files with 28 additions and 24 deletions

View File

@ -143,45 +143,49 @@ namespace GameEditor.Util
string[] files = Directory.GetFiles(desPath);
for (int i = 0; i < files.Length; i++)
{
string sourceExt = Path.GetExtension(files[i]);
if (sourceExt == ".meta")
{
continue;
}
string fileName = Path.GetFileName(files[i]);
string sourceFileName = Path.GetFileNameWithoutExtension(files[i]);
if (sourceFileName.EndsWith("_zh"))
{
sourceFileName = sourceFileName.Substring(0, sourceFileName.Length - 3);
}
string sourceExt = Path.GetExtension(files[i]);
}
string[] guids = AssetDatabase.FindAssets(sourceFileName + " t:Texture",new string[] { tag1 });
if (guids == null || guids.Length < 1)
{
continue;
}
bool isReplace = false;
for (int j = 0; j < guids.Length; j++)
if (guids != null && guids.Length > 0)
{
string desFilePath = AssetDatabase.GUIDToAssetPath(guids[j]);
string rootPath = Path.GetDirectoryName(desFilePath);
string desfileName = Path.GetFileName(desFilePath);
string desFileNameWithoutExt = Path.GetFileNameWithoutExtension(desFilePath);
if (desFileNameWithoutExt.EndsWith("_zh"))
for (int j = 0; j < guids.Length; j++)
{
desFileNameWithoutExt = desFileNameWithoutExt.Substring(0, desFileNameWithoutExt.Length - 3);
}
string desExt = Path.GetExtension(desFilePath);
if (sourceFileName == desFileNameWithoutExt)
{
isReplace = true;
if (sourceExt == desExt)
string desFilePath = AssetDatabase.GUIDToAssetPath(guids[j]);
string rootPath = Path.GetDirectoryName(desFilePath);
string desfileName = Path.GetFileName(desFilePath);
string desFileNameWithoutExt = Path.GetFileNameWithoutExtension(desFilePath);
if (desFileNameWithoutExt.EndsWith("_zh"))
{
AssetDatabase.CopyAsset("Assets/ImportFloder/" + fileName, desFilePath);
desFileNameWithoutExt = desFileNameWithoutExt.Substring(0, desFileNameWithoutExt.Length - 3);
}
else
string desExt = Path.GetExtension(desFilePath);
if (sourceFileName == desFileNameWithoutExt)
{
AssetDatabase.MoveAssetToTrash(desFilePath);
AssetDatabase.MoveAsset("Assets/ImportFloder/" + fileName, rootPath + "/" + fileName);
isReplace = true;
if (sourceExt == desExt)
{
AssetDatabase.CopyAsset("Assets/ImportFloder/" + fileName, desFilePath);
}
else
{
AssetDatabase.MoveAssetToTrash(desFilePath);
AssetDatabase.MoveAsset("Assets/ImportFloder/" + fileName, rootPath + "/" + fileName);
}
}
}
}
if (!isReplace)
{
AssetDatabase.MoveAsset("Assets/ImportFloder/" + fileName, Path.Combine(tag1, path) + "/" + fileName);