打开预制体或者场景文件,可以看到。
Paste_Image.png
用正则表达式来匹配替换即可。
[MenuItem("BabybusFrame/Utility/一键替换所有字体")]
private static void ReplaceText()
{
var fileID = "12800000";
var guid = "02dd88727fcbd8b46abd6f8636fec717";
var type = 3;
var pattern = "m_Font: {fileID: [0-9]+, guid: [0-9a-z]{32}, type: [0-9]+}";
var replacement = "m_Font: {fileID: " + fileID + ", guid: " + guid + ", type: " + type +"}";
var assets = AssetDatabase.FindAssets("t:Prefab t:SceneAsset");
for (var i = 0; i < assets.Length; i++)
{
var assetPath = AssetDatabase.GUIDToAssetPath(assets[i]);
EditorUtility.DisplayProgressBar("Hold on", assetPath, 1.0f * i / assets.Length);
var input = File.ReadAllText(assetPath);
var contents = Regex.Replace(input, pattern, replacement);
File.WriteAllText(assetPath, contents);
}
EditorUtility.ClearProgressBar();
AssetDatabase.Refresh();
}
网友评论