| | |
| | | using Snxxz.UI; |
| | | using UnityEngine; |
| | | using UnityEditor; |
| | | using System; |
| | | |
| | | public class DeleteStar : MonoBehaviour { |
| | | public class DeleteStar : MonoBehaviour |
| | | { |
| | | |
| | | [MenuItem("Prefab/DeleteStar")] |
| | | private static void DeleteStarInPrefab() |
| | | { |
| | | string[] ids = AssetDatabase.FindAssets("t:Prefab",new string[] { "Assets/ResourcesOut/UI/PriorityWindow" }); |
| | | //string[] path = new string[ids.Length]; |
| | | for(int i=0;i<ids.Length;i++) |
| | | try |
| | | { |
| | | string path= AssetDatabase.GUIDToAssetPath(ids[i]); |
| | | GameObject getObj = AssetDatabase.LoadAssetAtPath<GameObject>(path); |
| | | ItemCell[] itemCellList = getObj.transform.GetComponentsInChildren<ItemCell>(true);//返回这个物体下的item对形象的item脚本数组 |
| | | if (itemCellList == null) |
| | | var ids = new List<string>(); |
| | | ids.AddRange(AssetDatabase.FindAssets("t:Prefab", new string[] { "Assets/ResourcesOut/UI/Window" })); |
| | | ids.AddRange(AssetDatabase.FindAssets("t:Prefab", new string[] { "Assets/ResourcesOut/UI/PriorityWindow" })); |
| | | ids.AddRange(AssetDatabase.FindAssets("t:Prefab", new string[] { "Assets/ResourcesOut/UI/Prefab" })); |
| | | |
| | | var totalCount = ids.Count; |
| | | for (int i = 0; i < ids.Count; i++) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var itemCell in itemCellList) |
| | | { |
| | | if (itemCell.starlist != null) |
| | | var path = AssetDatabase.GUIDToAssetPath(ids[i]); |
| | | EditorUtility.DisplayProgressBar("整理ItemCell", string.Format("整理:{0}", path), i / (float)totalCount); |
| | | var getObj = AssetDatabase.LoadAssetAtPath<GameObject>(path); |
| | | var itemCellList = getObj.transform.GetComponentsInChildren<ItemCell>(true);//返回这个物体下的item对形象的item脚本数组 |
| | | if (itemCellList == null) |
| | | { |
| | | DestroyImmediate(itemCell.starlist, true); |
| | | EditorUtility.SetDirty(getObj); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | AssetDatabase.SaveAssets(); |
| | | AssetDatabase.Refresh(); |
| | | //GameObject getObj = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/ResourcesOut/UI/Window/test/StarTestObj.prefab"); |
| | | catch (Exception ex) |
| | | { |
| | | Debug.Log(ex); |
| | | } |
| | | finally |
| | | { |
| | | AssetDatabase.SaveAssets(); |
| | | AssetDatabase.Refresh(); |
| | | EditorUtility.ClearProgressBar(); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |