| | |
| | | using UnityEngine; |
| | | using UnityEditor; |
| | | using System.IO; |
| | | using UnityEngine.UI; |
| | | |
| | | public class ExportUIPackage |
| | | { |
| | |
| | | [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[] { windowReferenceConfigRoot })); |
| | | 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 })); |
| | |
| | | assets.Add(windowreferenceTable); |
| | | AssetDatabase.ExportPackage(assets.ToArray(), exportFileName, ExportPackageOptions.Default); |
| | | } |
| | | |
| | | |
| | | [MenuItem("策划工具/生成window参照表", false, 5)] |
| | | public static void ExportAllWindowNames() |