138 lines
5.6 KiB
C#
138 lines
5.6 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
public class MoveFile
|
|
{
|
|
[MenuItem("Tools/移动多语言图片到对应文件夹")]
|
|
static void MoveSelectedAssets()
|
|
{
|
|
string[] selectedPaths = Selection.assetGUIDs;
|
|
//string targetFolderPath = "Assets/NewFolder"; // 目标文件夹路径
|
|
//Directory.CreateDirectory(targetFolderPath); // 确保文件夹存在
|
|
|
|
foreach (string guid in selectedPaths)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
|
string[] splits = path.Split('/');
|
|
string[] results = AssetDatabase.FindAssets(splits[splits.Length - 1].Replace("_en.png", "_zh"));
|
|
if (results.Length > 0)
|
|
{
|
|
string newPath = AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets(splits[splits.Length - 1].Replace("_en.png", "_zh"))[0]);
|
|
//Debug.Log(path);
|
|
|
|
if (newPath.Contains("ArtFont_zh"))
|
|
{
|
|
newPath = newPath.Replace("ArtFont_zh", "ArtFont_en");
|
|
string forlder = newPath.Substring(0, newPath.LastIndexOf("/"));
|
|
Directory.CreateDirectory(forlder);
|
|
//Debug.Log(newPath);
|
|
AssetDatabase.DeleteAsset(forlder + "/" + splits[splits.Length - 1]);
|
|
AssetDatabase.MoveAsset(path, forlder + "/" + splits[splits.Length - 1]);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError(newPath);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError(path);
|
|
}
|
|
}
|
|
AssetDatabase.Refresh(); // 刷新AssetDatabase以显示更改
|
|
}
|
|
[MenuItem("Tools/复制缺失图片到对应文件夹")]
|
|
static void CopySelectedAssets()
|
|
{
|
|
string[] selectedPaths_vn = AssetDatabase.FindAssets("t:Texture2D", new[] { "Assets/ManagedResources/ArtFont_vn" });
|
|
foreach (string guid in selectedPaths_vn)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
|
if (path.EndsWith("_vn.png"))
|
|
{
|
|
string path_en = path.Replace("_vn.png", "_en.png");
|
|
path_en = path_en.Replace("ArtFont_vn", "ArtFont_en");
|
|
string results = AssetDatabase.AssetPathToGUID(path_en);
|
|
if (string.IsNullOrEmpty(results))
|
|
{
|
|
string[] split = path.Split('/');
|
|
string[] zhresults = AssetDatabase.FindAssets(split[split.Length-1].Replace("_vn.png", "_zh"));
|
|
if (zhresults.Length > 0)
|
|
{
|
|
string oldPath = AssetDatabase.GUIDToAssetPath(zhresults[0]);
|
|
string newPath = "Assets/tempatlas";
|
|
Directory.CreateDirectory(newPath);
|
|
newPath = newPath + "/" + oldPath.Substring(oldPath.LastIndexOf('/'));
|
|
AssetDatabase.CopyAsset(oldPath, newPath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
[MenuItem("Tools/比对韩语和英文差异")]
|
|
static void CheckVnEn()
|
|
{
|
|
string[] selectedPaths_vn = AssetDatabase.FindAssets("t:Texture2D", new[] { "Assets/ManagedResources/ArtFont_vn" });
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (string guid in selectedPaths_vn)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
|
if (path.EndsWith("_vn.png"))
|
|
{
|
|
path = path.Replace("_vn.png", "_en.png");
|
|
path = path.Replace("ArtFont_vn", "ArtFont_en");
|
|
string results = AssetDatabase.AssetPathToGUID(path);
|
|
if (string.IsNullOrEmpty(results))
|
|
{
|
|
string[] split = path.Split('/');
|
|
sb.Append(split[split.Length - 1] + "\n");
|
|
}
|
|
}
|
|
}
|
|
string content = sb.ToString();
|
|
Debug.Log(content);
|
|
}
|
|
[MenuItem("Assets/Checkzhs")]
|
|
static void Checkzhs()
|
|
{
|
|
string[] selectedPaths = Selection.assetGUIDs;
|
|
//string targetFolderPath = "Assets/NewFolder"; // 目标文件夹路径
|
|
//Directory.CreateDirectory(targetFolderPath); // 确保文件夹存在
|
|
|
|
foreach (string guid in selectedPaths)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
|
string[] splits = path.Split('/');
|
|
string name = splits[splits.Length - 1].Replace("en.png", "test");
|
|
if (name.Contains("_en"))
|
|
{
|
|
Debug.Log(name);
|
|
}
|
|
}
|
|
}
|
|
[MenuItem("Assets/Find All PNG Files")] // 添加一个菜单项来运行这个函数
|
|
static void FindAllPNGFiles()
|
|
{
|
|
string folderPath = "Assets/ManagedResources/ArtFont_en"; // 指定你的文件夹路径
|
|
string[] guids = AssetDatabase.FindAssets("t:Texture2D", new[] { folderPath });
|
|
foreach (var guid in guids)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
|
if (Path.GetExtension(path).ToLower() == ".png" && path.EndsWith("__en.png"))
|
|
{
|
|
string[] splits = path.Split('/');
|
|
string name = splits[splits.Length - 1].Replace("__en.png", "_en.png");
|
|
AssetDatabase.RenameAsset(path, name);
|
|
//if (name.Contains("_en"))
|
|
{
|
|
//name = name.Replace("_en","_zh") + "_en.png";
|
|
//AssetDatabase.RenameAsset(path,name);
|
|
}
|
|
}
|
|
}
|
|
AssetDatabase.Refresh(); // 刷新AssetDatabase以显示更改
|
|
}
|
|
}
|