[MenuItem("Tools/GenerateZhCharacter")] public static void GenerateZhCharacter() { var dataPath = Application.dataPath; var path = Path.Combine(dataPath, "Resources/zh_gene.txt"); List<string> exists = new List<string>(); StringBuilder builder = new StringBuilder(); builder.Append("!#$%&'()*,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{}~ ·ÀÂÄÇÈÉÊÎÔÖÜßàâäçèéêîïôöùûüŒœ—‘’“”…、。《》!(),:? 繁文"); var localizationAsset = Resources.Load<LanguageSourceAsset>("I2Languages");//此处为I2插件的Asset,自行修改为自己使用的插件或者文本文件然后遍历 Regex regex = new Regex(@"^[\u4E00-\u9FA5]{0,}$"); foreach (var iTerm in localizationAsset.mSource.mTerms) { Debug.Log(iTerm.Languages[4]); //繁体 for (int i = 0; i < iTerm.Languages[4].Length; i++) { var item = iTerm.Languages[4][i].ToString(); if (regex.IsMatch(item) && !exists.Contains(item)) { builder.Append(item); exists.Add(item); } } } foreach (var iTerm in localizationAsset.mSource.mTerms) { Debug.Log(iTerm.Languages[3]); //简体 for (int i = 0; i < iTerm.Languages[3].Length; i++) { var item = iTerm.Languages[3][i].ToString(); if (regex.IsMatch(item) && !exists.Contains(item)) { builder.Append(item); exists.Add(item); } } } File.WriteAllText(path,builder.ToString()); AssetDatabase.Refresh(); Debug.Log("最终的字符串:" + builder.ToString()); }
标签:exists,builder,中文字体,Languages,item,Unity,Editor,iTerm,var From: https://www.cnblogs.com/txfd/p/16994879.html