少年修仙传客户端基础资源
dabaoji
2025-06-09 8ee0256378cbf5dbc9d76ed10b60b65a844ef4dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using UnityEngine.UI;
using vnxbqy.UI;
using System.Text;
 
public class ImportPrefabsLanguage : EditorWindow {
 
    private static string topFilePath = Application.dataPath + "/ResourcesOut/UI";
 
    [MenuItem("策划工具/==给打标记预制体进行翻译==", false)]
    private static void Export()
    {
        Debug.Log("工具说明:语言表必须已翻译好,多执行几次直到不再修改!!! 一般只在新地区需要翻译的时候使用一次即可,后续开发由程序正常提取到语言表,不再使用此工具");
        string readPath = "Assets\\ResourcesOut\\Refdata\\Config\\Language.txt";
        if (!File.Exists(readPath))
        {
            Debug.LogError("语言表Assets\\ResourcesOut\\Refdata\\Config\\Language.txt 不存在");
            return;
        }
 
        string[] lines = File.ReadAllLines(readPath, Encoding.UTF8);
 
        if (lines.Length == 0)
        {
            Debug.LogError("读语言表失败");
        }
        else
        {
            Debug.Log("读语言表成功 " + lines.Length);
        }
        Dictionary<string, string> dic = new Dictionary<string, string>();
 
        for (int i = 3; i < lines.Length; i++)
        {
            string[] info = lines[i].Split('\t');
 
            string key;
            try
            {
                key = info[0];
                if (dic.ContainsKey(key))
                {
                    continue;
                }
                dic[key] = info[1];
            }
            catch (System.Exception)
            {
                Debug.LogError("解析失败" + lines[i] + " - 行号: " + i);
                continue;
            }
        }
 
        string[] filepaths = Directory.GetFiles(topFilePath, "*.prefab", SearchOption.AllDirectories);
        Debug.LogFormat("UI预制体文字路径{0}, {1}", topFilePath, filepaths.Length);
 
 
        int startIndex = 0;
        int changeCnt = 0;
        EditorApplication.update = delegate ()
        {
            if (startIndex >= lines.Length)
            {
                Debug.LogFormat("翻译结束-- 检索{0}个预制体,共翻译{1}个文本", startIndex, changeCnt);
                EditorUtility.ClearProgressBar();
                EditorApplication.update = null;
                startIndex = 0;
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                return;
            }
            string file = filepaths[startIndex];
            file = file.Substring(file.IndexOf("Assets"));
            bool isCancel = EditorUtility.DisplayCancelableProgressBar("翻译预制体文字-" + filepaths.Length, file, (float)startIndex / (float)filepaths.Length);
            GameObject _prefab = AssetDatabase.LoadAssetAtPath<GameObject>(file);
 
            UITextMark[] transArr14 = _prefab.GetComponentsInChildren<UITextMark>(true);
 
 
            foreach (UITextMark item in transArr14)
            {
                Text tmpText = item.GetComponent<Text>();
                if (tmpText == null)
                {
                    Debug.LogErrorFormat("异常:第{0}行翻译失败{1},{2}", startIndex, file, item.name);
                    continue;
                }
                
                if (!dic.ContainsKey(item.language))
                {
                    Debug.LogErrorFormat("异常:第{0}行翻译失败{1},{2}, 语言表 key不存在 {3}", startIndex, file, item.name, item.language);
                    continue;
                }
 
                if (tmpText.text != dic[item.language])
                {
                    //Debug.LogFormat("翻译成功--{0} , {1}; {2} - {3}", file, item.name, tmpText.text, dic[item.language]);
                    tmpText.text = dic[item.language];
                    EditorUtility.SetDirty(_prefab);
                    changeCnt++;
                }
 
            }
            startIndex++;
 
            if (isCancel || startIndex >= filepaths.Length)
            {
                Debug.LogFormat("翻译结束-- 检索{0}个预制体,共翻译{1}个文本", startIndex, changeCnt);
                EditorUtility.ClearProgressBar();
                EditorApplication.update = null;
                startIndex = 0;
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
 
            }
        };
 
 
    }
 
 
}
 
//[MenuItem("策划工具/==批量给预制体打标记==", false)]
//private static void Export()
//{
//    string writePath = "importUITextMark.txt";
//    if (!File.Exists(writePath))
//    {
//        return;
//    }
 
//    string[] lines = File.ReadAllLines(writePath, Encoding.UTF8);
 
//    int startIndex = 0;
//    int changeCnt = 0;
//    EditorApplication.update = delegate () {
//        if (startIndex >= lines.Length)
//        {
//            Debug.LogFormat("批量标记修改成功-- 检索{0}行,共替换{1}行", startIndex, changeCnt);
//            EditorUtility.ClearProgressBar();
//            EditorApplication.update = null;
//            startIndex = 0;
//            AssetDatabase.SaveAssets();
//            AssetDatabase.Refresh();
//            return;
//        }
//        var lineStr = lines[startIndex];
//        string[] info = lines[startIndex].Split('\t');
//        startIndex++;
//        if (info.Length != 7)
//        {
//            Debug.LogFormat("异常:长度不对--执行到:第{0}行 {1}", startIndex, lineStr);
//            return;
//        }
//        string file = info[0];
//        int index = int.Parse(info[1]);
//        string name = info[2];
//        string content = info[5];
 
//        bool isCancel = EditorUtility.DisplayCancelableProgressBar("导入预制体文字-" + lines.Length, file, (float)startIndex / (float)lines.Length);
//        GameObject _prefab = AssetDatabase.LoadAssetAtPath<GameObject>(file);
//        if (_prefab == null)
//        {
//            if (isCancel)
//            {
 
//                EditorUtility.ClearProgressBar();
//                EditorApplication.update = null;
//                startIndex = 0;
//                AssetDatabase.SaveAssets();
//                AssetDatabase.Refresh();
//            }
//            Debug.LogFormat("异常:预制体异常--执行到:第{0}行 {1}", startIndex, lineStr);
//            return;
//        }
//        Text[] transArr = _prefab.GetComponentsInChildren<Text>(true);
 
//        Text item = transArr[index];
//        if (item.name == name)
//        {
//            var mark = item.GetComponent<UITextMark>();
//            if (mark == null)
//            {
//                mark = item.gameObject.AddComponent<UITextMark>();
//                mark.language = content;
//                EditorUtility.SetDirty(_prefab);
//                changeCnt++;
//                //Debug.LogFormat("字体批量文件--{0} , {1}", file, index);
//            }
//            else if (mark.language != content)
//            {
//                Debug.LogErrorFormat("异常:第{0}行替换失败{1},{2}", startIndex, file, name);
//            }
//        }
//        else
//        {
//            Debug.LogErrorFormat("异常:第{0}行替换失败{1},{2}", startIndex, file, name);
//        }
 
//        if (isCancel || startIndex >= lines.Length)
//        {
//            Debug.LogFormat("文字批量修改成功-- 检索{0}行,共替换{1}行", startIndex, changeCnt);
//            EditorUtility.ClearProgressBar();
//            EditorApplication.update = null;
//            startIndex = 0;
//            AssetDatabase.SaveAssets();
//            AssetDatabase.Refresh();
//        }
//    };
 
 
 
//    Debug.LogFormat("导入翻译完成");
 
//}
//导出和语言表共用的key,如果没有生成唯一key
//private static void Export()
//{
//    // 将港台的中文 写入到越南的表中
//    //Language  import3
//    string readPath = "Assets\\ResourcesOut\\Refdata\\Config\\Language.txt";
//    if (!File.Exists(readPath))
//    {
//        return;
//    }
 
//    string[] lines = File.ReadAllLines(readPath, Encoding.UTF8);
 
//    if (lines.Length == 0)
//    {
//        Debug.LogError("读语言表失败");
//    }
//    else
//    {
//        Debug.Log("读语言表成功 " + lines.Length);
//    }
//    Dictionary<string, string> dic = new Dictionary<string, string>();
 
//    for (int i = 3; i < lines.Length; i++)
//    {
//        string[] info = lines[i].Split('\t');
 
//        string key;
//        try
//        {
//            key = info[1];
//        }
//        catch (System.Exception)
//        {
//            Debug.LogError("读语言表失败" + lines[i] + " - " + i);
//            continue;
//        }
//        if (dic.ContainsKey(key))
//        {
//            continue;
//        }
//        dic[key] = info[0];
//    }
 
//    string[] linesZH = File.ReadAllLines("import3.txt", Encoding.UTF8);
 
 
//    Dictionary<string, string> dicZH = new Dictionary<string, string>();
//    SortedDictionary<string, string[]> dicZHList = new SortedDictionary<string, string[]>();
 
 
//    for (int i = 0; i < linesZH.Length; i++)
//    {
//        string[] info = linesZH[i].Split('\t');
 
//        var key = info[0] + "_" + info[1] + "_" + info[2];
//        dicZHList[key] = info;
 
//        if (string.IsNullOrEmpty(info[5].Trim()))
//        {
//            continue;
//        }
 
//        if (dicZH.ContainsKey(info[6]))
//        {
//            continue;
//        }
//        dicZH[info[6]] = info[5];
//    }
 
//    string writePath = "exportUILanguage3.txt";
//    if (File.Exists(writePath))
//    {
//        File.Delete(writePath);
//    }
//    FileStream fs = new FileStream(writePath, FileMode.Create);//如不存在,则创建新的文本文档
 
//    //1.找语言表有的写入line
//    //2.找语言表没有的 查找缓存,缓存没有的写入缓存 并写入line
//    foreach (var item in dicZHList)
//    {
//        var key = item.Key;
//        var line = item.Value;
 
//        var lineList = new List<string>(line);
 
//        bool islan = false;
//        if (string.IsNullOrEmpty(lineList[5].Trim()))
//        {
 
//            if (dic.ContainsKey(lineList[6]))
//            {
//                lineList[5] = dic[lineList[6]];
//                islan = true;
//            }
//            else if (dicZH.ContainsKey(lineList[6]))
//            {
//                lineList[5] = dicZH[lineList[6]];
//            }
//            else
//            {
//                dicZH[lineList[6]] = lineList[3];
//                lineList[5] = lineList[3];
//            }
//        }
//        else
//        {
//            if (dic.ContainsKey(lineList[6]))
//            {
//                islan = true;
//            }
//        }
 
//        string newLine = string.Join("\t", lineList);
//        newLine = newLine + "\t" + islan + "\r\n";
 
//        byte[] data1 = System.Text.Encoding.UTF8.GetBytes(newLine);
//        fs.Write(data1, 0, data1.Length);
//    }
 
//    fs.Close();
 
 
//    Debug.LogFormat("导出完成");
 
//}
 
// 将key读取从text的内容 移植到 keyname中
 
//public class ImportPrefabsLanguage : EditorWindow
//{
 
 
//    [MenuItem("策划工具/==批量导入预制体语言表设置==", false)]
//    private static void Export()
//    {
 
//        string writePath = "importUILanguage.txt";
//        if (!File.Exists(writePath))
//        {
//            return;
//        }
 
//        string[] lines = File.ReadAllLines(writePath, Encoding.UTF8);
 
//        int startIndex = 1;
//        int changeCnt = 0;
//        EditorApplication.update = delegate () {
//            if (startIndex >= lines.Length)
//            {
//                Debug.LogFormat("语言表文字批量修改成功-- 检索{0}行,共替换{1}行", startIndex, changeCnt);
//                EditorUtility.ClearProgressBar();
//                EditorApplication.update = null;
//                startIndex = 0;
//                AssetDatabase.SaveAssets();
//                AssetDatabase.Refresh();
//                return;
//            }
//            var lineStr = lines[startIndex];
//            string[] info = lines[startIndex].Split('\t');
//            startIndex++;
//            if (info.Length != 8)
//            {
//                Debug.LogFormat("异常:长度不对--执行到:第{0}行 {1}", startIndex, lineStr);
//                return;
//            }
//            string file = info[0];
//            int index = int.Parse(info[1]);
//            string name = info[2];
//            string content = info[4].Replace("\r", "").Replace("\n", "");
//            int state;
//            int.TryParse(info[7], out state);
 
//            bool isCancel = EditorUtility.DisplayCancelableProgressBar("导入预制体语言key-" + lines.Length, file, (float)startIndex / (float)lines.Length);
//            GameObject _prefab = AssetDatabase.LoadAssetAtPath<GameObject>(file);
//            if (_prefab == null)
//            {
//                if (isCancel)
//                {
 
//                    EditorUtility.ClearProgressBar();
//                    EditorApplication.update = null;
//                    startIndex = 0;
//                    AssetDatabase.SaveAssets();
//                    AssetDatabase.Refresh();
//                }
//                Debug.LogFormat("异常:预制体异常--执行到:第{0}行 {1}", startIndex, lineStr);
//                return;
//            }
//            Text[] transArr = _prefab.GetComponentsInChildren<Text>(true);
 
//            Text item = transArr[index];
//            if (item.name == name)
//            {
//                if (state == 1)
//                {
//                    bool reset = false;
//                    TextEx tmpTextEx = item as TextEx;  //TextImage 是TextEx的子类
//                    if ((tmpTextEx != null && tmpTextEx.isKey))
//                    {
//                        if (tmpTextEx.keyName != content)
//                        {
//                            tmpTextEx.keyName = content;
//                            reset = true;
//                        }
//                    }
 
//                    RichText tmpRichText = item as RichText;
//                    if ((tmpRichText != null && tmpRichText.language))
//                    {
//                        if (tmpRichText.enableDisplay != content)
//                        {
//                            tmpRichText.enableDisplay = content;
//                            reset = true;
//                        }
//                    }
 
//                    if (reset)
//                    {
//                        EditorUtility.SetDirty(_prefab);
//                        changeCnt++;
//                        //Debug.LogFormat("字体批量文件--{0} , {1}", file, index);
//                    }
//                }
//            }
//            else
//            {
//                Debug.LogErrorFormat("异常:第{0}行替换失败{1},{2}", startIndex, file, name);
//            }
 
//            if (isCancel || startIndex >= lines.Length)
//            {
//                Debug.LogFormat("文字key批量修改成功-- 检索{0}行,共替换{1}行", startIndex, changeCnt);
//                EditorUtility.ClearProgressBar();
//                EditorApplication.update = null;
//                startIndex = 0;
//                AssetDatabase.SaveAssets();
//                AssetDatabase.Refresh();
//            }
//        };
 
 
//    }
 
 
//}