少年修仙传客户端基础资源
dabaoji
2025-06-04 34d28a982a741d63f183884881b0bea73f8c8b47
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Text.RegularExpressions;
using UnityEngine.UI;
 
public class ThirdLevelFrameProcessor
{
    [MenuItem("程序/加载三级界面")]
    public static void CreateAllThirdLevelFrame()
    {
        var oldSprite1 = UILoader.LoadSprite("1LevelFrame", "TY_K_3J_2");
        var oldSprite2 = UILoader.LoadSprite("1LevelFrame", "TY_K_3J_1");
        var oldSprite3 = UILoader.LoadSprite("4Interactable", "Close_a");
 
        var newSprite1 = UILoader.LoadSprite("1LevelFrame", "ThirdLevel_Frame");
        var newSprite2 = UILoader.LoadSprite("1LevelFrame", "ThirdLevel_Bg");
        var newSprite3 = UILoader.LoadSprite("1LevelFrame", "ThirdLevel_Close");
 
        var path = AssetDatabase.GetAssetPath(newSprite1);
        var guid = AssetDatabase.AssetPathToGUID(path);
 
        var path1 = AssetDatabase.GetAssetPath(oldSprite1);
        var guid1 = AssetDatabase.AssetPathToGUID(path1);
 
        var path2 = AssetDatabase.GetAssetPath(oldSprite2);
        var guid2 = AssetDatabase.AssetPathToGUID(path2);
 
        var path3 = AssetDatabase.GetAssetPath(oldSprite3);
        var guid3 = AssetDatabase.AssetPathToGUID(path3);
 
        var allwindowGuids = AssetDatabase.FindAssets("t: prefab", new string[] { "Assets/ResourcesOut/UI/Window" });
        var totalCount = allwindowGuids.Length;
        var count = 0;
 
        foreach (var windowGuid in allwindowGuids)
        {
            count++;
            var windowPath = AssetDatabase.GUIDToAssetPath(windowGuid);
            var content = File.ReadAllText(Application.dataPath + windowPath.Substring(6, windowPath.Length - 6));
 
            GameObject instance = null;
            GameObject prefab = null;
 
            if (Regex.IsMatch(content, guid))
            {
                prefab = AssetDatabase.LoadAssetAtPath<GameObject>(windowPath);
                instance = GameObject.Instantiate(prefab);
                instance.name = prefab.name;
                instance.SetActive(true);
                PrefabUtility.ConnectGameObjectToPrefab(instance, prefab);
            }
 
            continue;
 
            if (prefab == null)
            {
                continue;
            }
 
            Vector2 min = Vector2.zero;
            Vector2 max = Vector2.zero;
 
            var width = 0f;
 
            var images = prefab.GetComponentsInChildren<Image>(true);
 
            foreach (var image in images)
            {
                if (image.sprite == oldSprite1)
                {
                    max = UIUtility.GetMaxWorldPosition(image.rectTransform);
                    width = image.rectTransform.rect.width;
                }
            }
 
            foreach (var image in images)
            {
                if (image.sprite == oldSprite2 && min == Vector2.zero)
                {
                    min = UIUtility.GetMinWorldPosition(image.rectTransform);
                }
            }
 
            Image image1 = null;
            Image image2 = null;
            Image image3 = null;
 
            foreach (var image in images)
            {
                if (image.sprite == oldSprite1)
                {
                    image1 = image;
                    var rectTransform = image.rectTransform;
                    var oldHeight = rectTransform.rect.height;
 
                    image.sprite = newSprite1;
                    image.type = Image.Type.Sliced;
                    image.transform.SetAsLastSibling();
                    rectTransform.pivot = rectTransform.anchorMax = rectTransform.anchorMin = Vector2.one * 0.5f;
 
                    var x1 = max.y - oldHeight;
                    var x2 = (max.y - min.y) * 0.5f - oldHeight;
                    var y = x1 - x2;
 
                    max = max.SetY(max.y - 3.5f);
 
                    rectTransform.sizeDelta = new Vector2(width + 13, (max.y - min.y));
                    rectTransform.anchoredPosition = new Vector2((max.x + min.x) - 3.5f, y - 3.5f);
                }
            }
 
            foreach (var image in images)
            {
                if (image.sprite == oldSprite2)
                {
                    if (image2 == null)
                    {
                        image2 = image;
                        var rectTransform = image.rectTransform;
 
                        image.sprite = newSprite2;
                        image.type = Image.Type.Simple;
                        rectTransform.pivot = Vector2.one * 0.5f;
                        rectTransform.sizeDelta = image1.rectTransform.sizeDelta - new Vector2(55, 23);
                        rectTransform.position = image1.transform.position - new Vector3(0, 8f, 0);
                        var mirrorImage = image2.transform.GetComponent<MirrorImage>();
                        if (mirrorImage)
                        {
                            Object.DestroyImmediate(mirrorImage, true);
                        }
                    }
                    else
                    {
                        GameObject.DestroyImmediate(image.gameObject, true);
                    }
                }
            }
 
            foreach (var image in images)
            {
                if (image.sprite == oldSprite3 && image.gameObject.activeSelf)
                {
                    image3 = image;
                    var rectTransform = image.rectTransform;
 
                    image.sprite = newSprite3;
                    image.SetNativeSize();
                    image.transform.SetParent(image1.transform);
                    image.transform.SetAsLastSibling();
 
                    rectTransform.position = image1.transform.position
                        + new Vector3(image1.rectTransform.rect.width * 0.5f, image1.rectTransform.rect.height * 0.5f, 0f)
                        - new Vector3(33f, 2.3f, 0f);
                }
            }
 
            EditorUtility.DisplayProgressBar("处理中三级界面", "处理中...", (float)count / totalCount);
        }
 
        EditorUtility.ClearProgressBar();
    }
 
 
 
 
 
}