少年修仙传客户端基础资源
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using UnityEngine.UI;
 
public class ExportUIPackage
{
 
    static string exportFileName = Application.dataPath + "/UIPackage.unitypackage";
    static string uiroot = "Assets/ResourcesOut/UI";
    static string builtIn = "Assets/ResourcesOut/BuiltIn/Prefabs";
    static string windowreferenceTable = "Assets/Editor/Config/Windows.txt";
 
    [MenuItem("策划工具/导出UI Package", false, 4)]
    public static void Export()
    {
        var windowGuids = new List<string>();
        windowGuids.AddRange(AssetDatabase.FindAssets("Win t:prefab", new string[] { builtIn }));
        windowGuids.AddRange(AssetDatabase.FindAssets("Win t:prefab", new string[] { uiroot }));
 
        var windowReferenceConfigRoot = Application.dataPath + "/WindowAssets/";
        if (!Directory.Exists(windowReferenceConfigRoot))
        {
            Directory.CreateDirectory(windowReferenceConfigRoot);
        }
 
        var windowAssets = new List<string>();
        foreach (var item in windowGuids)
        {
            var path = AssetDatabase.GUIDToAssetPath(item);
            var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
            var fileName = Path.GetFileNameWithoutExtension(path);
 
            var sprites = new List<string>();
            var components = prefab.GetComponentsInChildren<Image>(true);
            foreach (var image in components)
            {
                if (image.sprite != null)
                {
                    var spritePath = AssetDatabase.GetAssetPath(image.sprite).Replace("Assets/", "");
                    if (!sprites.Contains(spritePath))
                    {
                        sprites.Add(spritePath);
                    }
                }
            }
 
            File.WriteAllLines(windowReferenceConfigRoot + fileName + ".txt", sprites.ToArray(), System.Text.Encoding.UTF8);
        }
 
        var guids = new List<string>();
        guids.AddRange(AssetDatabase.FindAssets("t:TextAsset", new string[] { "Assets/WindowAssets" }));
        guids.AddRange(AssetDatabase.FindAssets("t:prefab", new string[] { builtIn }));
        guids.AddRange(AssetDatabase.FindAssets("Font", new string[] { uiroot }));
        guids.AddRange(AssetDatabase.FindAssets("t:prefab", new string[] { uiroot }));
        guids.AddRange(AssetDatabase.FindAssets("t:Texture2D", new string[] { uiroot }));
        guids.AddRange(AssetDatabase.FindAssets("t:Sprite", new string[] { uiroot }));
 
        var assets = new List<string>();
        foreach (var item in guids)
        {
            assets.Add(AssetDatabase.GUIDToAssetPath(item));
        }
 
        assets.Add(windowreferenceTable);
        AssetDatabase.ExportPackage(assets.ToArray(), exportFileName, ExportPackageOptions.Default);
    }
 
    [MenuItem("策划工具/生成window参照表", false, 5)]
    public static void ExportAllWindowNames()
    {
        var lines = new List<string>();
        var filePath = Application.dataPath + "/Editor/Config/Windows.txt";
        if (File.Exists(filePath))
        {
            lines.AddRange(File.ReadAllLines(filePath, System.Text.Encoding.UTF8));
        }
 
        var windowNames = new List<string>();
        foreach (var item in lines)
        {
            windowNames.Add(item.Split('\t')[0]);
        }
 
        var guids = new List<string>();
        guids.AddRange(AssetDatabase.FindAssets("Win t:prefab", new string[] { builtIn }));
        guids.AddRange(AssetDatabase.FindAssets("Win t:prefab", new string[] { uiroot }));
 
        var assets = new List<string>();
        foreach (var item in guids)
        {
            var name = Path.GetFileNameWithoutExtension(AssetDatabase.GUIDToAssetPath(item));
            if (!windowNames.Contains(name))
            {
                lines.Add(StringUtility.Contact(name, "\t"));
            }
        }
 
        File.WriteAllLines(filePath, lines.ToArray(), System.Text.Encoding.UTF8);
    }
 
}