增加prefab导出多语言

This commit is contained in:
wuwenbo 2025-08-23 16:46:59 +08:00
parent 74c84f3bcf
commit 1aa6010c6b

View File

@ -394,6 +394,24 @@ namespace Logic.Editor
}
var coms = uiObj.GetComponentsInChildren<TextMeshProUGUI>(true).ToList();
// 处理 Assets/Resources/Prefab 路径下的所有 prefab
var prefabList = new List<GameObject>();
var prefabPath = $"Assets/Resources/Prefab/";
if (Directory.Exists(prefabPath))
{
string[] prefabPaths = Directory.GetFiles(prefabPath, "*.prefab", SearchOption.AllDirectories);
foreach (var prefabAssetPath in prefabPaths)
{
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(prefabAssetPath);
if (!prefab) continue;
var prefabComs = prefab.GetComponentsInChildren<TextMeshProUGUI>(true).ToList();
if (prefabComs.Count == 0) continue;
foreach (var com in prefabComs)coms.Add(com);
prefabList.Add(prefab);
}
}
foreach (var com in coms)
{
if (!Regex.IsMatch(com.text, @"[\u4E00-\u9FFF\u3400-\u4DBFa-zA-Z]")) continue;
@ -415,7 +433,7 @@ namespace Logic.Editor
}
_activeSet.Add(textCom.ID);
}
var path = $"Assets/Resources/DataAssets/";
string[] assetPaths = Directory.GetFiles(path, "*.asset", SearchOption.AllDirectories);
foreach (var assetPath in assetPaths)
@ -461,6 +479,7 @@ namespace Logic.Editor
WriteToExcel();
foreach (var prefab in prefabList) EditorUtility.SetDirty(prefab);
EditorUtility.SetDirty(_asset);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();