三国卡牌客户端基础资源仓库
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
using UnityEngine;
using UnityEditor;
using System.IO;
using UnityEngine.UI;
 
 
//检查window界面里是否引用了builtin里的图片
public class ExportPrefabsNoBuiltin : EditorWindow {
 
    private static string topFilePath= "Assets/ResourcesOut/UI/";
 
 
 
    [UnityEditor.MenuItem("策划工具/检查window界面是否包含builtin图片", false)]
    private static void Export2()
    {
        string[] filepaths = Directory.GetFiles(topFilePath, "*.prefab", SearchOption.AllDirectories);
        Debug.LogFormat("检查预制体总数:{0}", filepaths.Length);
        int startIndex = 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);
 
            Image[] transArr14 = _prefab.GetComponentsInChildren<Image>(true);
 
            foreach (Image item in transArr14)
            {
                var path = AssetDatabase.GetAssetPath(item.sprite.GetInstanceID());
                if (string.IsNullOrEmpty(path)) continue;
                if (path.Contains("BuiltIn"))
                {
                    Debug.LogErrorFormat("包含BuiltIn图片 {0} - {1} - {2}", file, path, item.name);
                }
            }
            startIndex++;
 
            if (isCancel || startIndex >= filepaths.Length)
            {
                Debug.LogFormat("检查结束");
                EditorUtility.ClearProgressBar();
                EditorApplication.update = null;
                startIndex = 0;
 
            }
        };
 
 
    }
 
}