using System.Collections; using System.Collections.Generic; using System.IO; using UnityEditor; using UnityEngine; using UnityEngine.UI; namespace GameEditor.Core { public class FindItemAddScript { [MenuItem("Tools/预制批量根据某一组件添加另外组件")] public static void Find() { //查找所有预制 var resourcesPath = Application.dataPath; var absolutePaths = System.IO.Directory.GetFiles(resourcesPath, "*.prefab", System.IO.SearchOption.AllDirectories); for (int i = 0; i < absolutePaths.Length; i++) { EditorUtility.DisplayProgressBar("查找添加", "查找添加中:" + (float)i + "/" + absolutePaths.Length, (float)i / absolutePaths.Length); string path = "Assets" + absolutePaths[i].Remove(0, resourcesPath.Length); path = path.Replace("\\", "/"); GameObject prefab = AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)) as GameObject; if (prefab != null) { //使用修改Button类型 List