using System.Collections; using UnityEngine; using System.IO; using UnityEditor; public class RenamePrefab : Editor { [MenuItem("Tools/重命名预设")] public static void Rename() { string folderPath = "Assets/ManagedResources/Prefabs/x1_battle"; // 修改为你的预制件文件夹路径 string[] prefabGuids = AssetDatabase.FindAssets("t:Prefab", new[] { folderPath }); foreach (var guid in prefabGuids) { string path = AssetDatabase.GUIDToAssetPath(guid); string oldName = Path.GetFileNameWithoutExtension(path); string newName = oldName.Replace("SkeletonGraphic (",""); // 修改为新的名称格式 newName = newName.Replace(")", ""); // 修改为新的名称格式 //Debug.Log(oldName+ "/" + newName); AssetDatabase.RenameAsset(path, newName); } AssetDatabase.Refresh(); // 刷新Asset数据库以应用更改 } [MenuItem("Tools/recttransform预设")] public static void RectTransformPrefab() { string folderPath = "Assets/ManagedResources/Prefabs/X1Effect/Battle"; // 修改为你的预制件文件夹路径 string[] prefabGuids = AssetDatabase.FindAssets("t:Prefab", new[] { folderPath }); foreach (var guid in prefabGuids) { string path = AssetDatabase.GUIDToAssetPath(guid); var prefab = PrefabUtility.LoadPrefabContents(path); var transes = prefab.GetComponentsInChildren(); foreach(var t in transes) { t.gameObject.AddComponent(); } PrefabUtility.SaveAsPrefabAsset(prefab,path); PrefabUtility.UnloadPrefabContents(prefab); } AssetDatabase.Refresh(); // 刷新Asset数据库以应用更改 } [MenuItem("Tools/改变子节点缩放")] public static void ChangeScale() { string folderPath = "Assets/ManagedResources/Prefabs/X1Effect/Battle"; // 修改为你的预制件文件夹路径 string[] prefabGuids = AssetDatabase.FindAssets("t:Prefab", new[] { folderPath }); foreach (var guid in prefabGuids) { string path = AssetDatabase.GUIDToAssetPath(guid); var prefab = PrefabUtility.LoadPrefabContents(path); for (int i =0;i