70 lines
2.7 KiB
C#
70 lines
2.7 KiB
C#
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<Transform>();
|
|
foreach(var t in transes)
|
|
{
|
|
t.gameObject.AddComponent<RectTransform>();
|
|
}
|
|
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<prefab.transform.childCount;i++)
|
|
{
|
|
var trans = prefab.transform.GetChild(i);
|
|
trans.transform.localScale = trans.transform.localScale * 0.333f;
|
|
}
|
|
PrefabUtility.SaveAsPrefabAsset(prefab, path);
|
|
PrefabUtility.UnloadPrefabContents(prefab);
|
|
}
|
|
|
|
AssetDatabase.Refresh(); // 刷新Asset数据库以应用更改
|
|
}
|
|
}
|