少年修仙传客户端基础资源
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using UnityEngine.UI;
using vnxbqy.UI;
using System.Reflection;
 
// 导出文本规格,如长宽,字体,字号,颜色,描边,阴影,行间距
public class ExportPrefabsWordFormat : EditorWindow {
 
    private static string topFilePath=Application.dataPath + "/ResourcesOut/UI";
 
 
    [MenuItem("策划工具/批量导出预制体文本格式", false)]
    private static void Export()
    {
 
        string writePath = "exportFontSize.txt";
        if (File.Exists(writePath))
        {
            File.Delete(writePath);
        }
        FileStream fs = new FileStream(writePath,FileMode.Create);//如不存在,则创建新的文本文档
        string writeline1 = string.Format("路径\t索引\t名字\t宽\t高\tanchorMinX\tanchorMinY\tanchorMaxX\tanchorMaxY\tanchoredPositionX\tanchoredPositionY\tpivotX\tpivotY\tlocalScaleX\tlocalScaleY\t字大小\t对齐\t行宽\t横溢出\t竖溢出\t自适应\t自适应最小\t自适应最大\r\n");
        byte[] data1 = System.Text.Encoding.UTF8.GetBytes(writeline1);
        fs.Write(data1, 0, data1.Length);
 
        topFilePath = Application.dataPath + "/ResourcesOut/UI";
 
        string[] filepaths1 = Directory.GetFiles(topFilePath, "*.prefab", SearchOption.AllDirectories);
        Debug.LogFormat("批量导出UI预制体文本格式路径{0}, {1}", topFilePath, filepaths1.Length);
        
        topFilePath = Application.dataPath + "/ResourcesOut/BuiltIn";
 
        string[] filepaths2 = Directory.GetFiles(topFilePath, "*.prefab", SearchOption.AllDirectories);
        Debug.LogFormat("批量导出BuiltIn预制体文本格式路径{0}, {1}", topFilePath, filepaths2.Length);
 
        string[] filepaths = new string[filepaths1.Length + filepaths2.Length];
 
        filepaths1.CopyTo(filepaths, 0);
        filepaths2.CopyTo(filepaths, filepaths1.Length);
        Debug.LogFormat("批量导出预制体总数:{0}", filepaths.Length);
        int startIndex = 0;
 
        int a = 0;
        int b = 0;
        int c = 0;
        int d = 0;
        int e = 0;
        EditorApplication.update = delegate () {
            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);
 
            Text[] transArr14 = _prefab.GetComponentsInChildren<Text>(true);
            a += transArr14.Length;
            RichText[] transArr11 = _prefab.GetComponentsInChildren<RichText>(true);
            b += transArr11.Length;
            TextImage[] transArr12 = _prefab.GetComponentsInChildren<TextImage>(true);
            c += transArr12.Length;
            OffsetImage2[] transArr13 = _prefab.GetComponentsInChildren<OffsetImage2>(true);
            d += transArr13.Length;
            TextEx[] transArr = _prefab.GetComponentsInChildren<TextEx>(true);
            e += transArr.Length;
            //Debug.LogFormat("{0}包含TextEx个数 {1}", file, transArr.Length);
            int i = 0;
            foreach (Text item in transArr14)
            {
 
                var test1 = item as TextImage;
                if (test1 != null)
                {
                    i++;
                    continue;
                }
                var test2 = item as OffsetImage2;
                if (test2 != null)
                {
                    i++;
                    continue;
                }
 
                RectTransform rectTransform = item.GetComponent<RectTransform>();
                string writeline = string.Format($"{file}\t{i}\t{item.name}\t{rectTransform.sizeDelta.x}\t{rectTransform.sizeDelta.y}\t{rectTransform.anchorMin.x}\t{rectTransform.anchorMin.y}\t{rectTransform.anchorMax.x}\t{rectTransform.anchorMax.y}\t{rectTransform.anchoredPosition.x}\t{rectTransform.anchoredPosition.y}\t{rectTransform.pivot.x}\t{rectTransform.pivot.y}\t{rectTransform.localScale.x}\t{rectTransform.localScale.y}\t{item.fontSize}\t{item.alignment}\t{item.lineSpacing}\t{item.horizontalOverflow}\t{item.verticalOverflow}\t{item.resizeTextForBestFit}\t{item.resizeTextMinSize}\t{item.resizeTextMaxSize}\r\n");
                byte[] data = System.Text.Encoding.UTF8.GetBytes(writeline);
                fs.Write(data, 0, data.Length);
                i++;
 
            }
            startIndex++;
 
            if (isCancel || startIndex >= filepaths.Length) {
                Debug.LogFormat("Text:{0},RichText:{1},TextImage:{2},OffsetImage2:{3},TextEx:{4}", a,b,c,d,e);
                EditorUtility.ClearProgressBar();
                EditorApplication.update = null;
                startIndex = 0;
                fs.Flush();
                fs.Close();//关闭
 
 
            }
        };
 
    
    }
 
  
}