public static void RefreshImage() { string[] sdirs = { "Assets/Art/UIPrefab", "Assets/Editor Default Resources" }; var asstIds = AssetDatabase.FindAssets("t:Prefab", sdirs); List <GameObject> gameObjects = new List <GameObject>(); foreach (var asstId in asstIds) { string path = AssetDatabase.GUIDToAssetPath(asstId); var pfb = AssetDatabase.LoadAssetAtPath <GameObject>(path); gameObjects.Add(pfb); } int i = 0; List <UIImage> images = new List <UIImage>(); foreach (var pfb in gameObjects) { bool exist = false; foreach (var image in pfb.GetComponentsInChildren <MyImage>(true)) { images.Add(new UIImage() { Index = i, Name = image.name, SpriteName = image.SpriteName }); image.Index = i; i++; exist = true; } if (exist) { try { PrefabUtility.SavePrefabAsset(pfb); } catch (Exception e) { Debug.LogWarning(e.Message); } } } //excel文本 UIImageManager imageManager = new UIImageManager { Images = images }; AssetDatabase.CreateAsset(imageManager, $"{ExcelConfig.assetPath}UIImageManager.asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
protected override void Start() { base.Start(); #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif if (SpriteName.Count != 0) { Factory = FactoryManager.GetFactory(); if (ImageManager == null) { ImageManager = Factory.GetResource <UIImageManager>("UIImageManager"); } ChangeSprite(); } }