New file |
| | |
| | | using UnityEngine; |
| | | using UnityEditor; |
| | | using System.IO; |
| | | using UnityEngine.UI; |
| | |
|
| | |
|
| | | //检查window界面里是否引用了builtin里的图片
|
| | | public class ExportPrefabsNoBuiltin : EditorWindow { |
| | | |
| | | private static string topFilePath= "Assets/ResourcesOut/UI/Window/"; |
| | |
|
| | |
|
| | |
|
| | | [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; |
| | | |
| | | } |
| | | };
|
| | |
|
| | |
|
| | | }
|
| | | |
| | | } |