diff --git a/Assets/Scripts/Editor/MyUIUtil.cs b/Assets/Scripts/Editor/MyUIUtil.cs index 635c576..dc058cc 100644 --- a/Assets/Scripts/Editor/MyUIUtil.cs +++ b/Assets/Scripts/Editor/MyUIUtil.cs @@ -1,3 +1,4 @@ +using System.IO; using TMPro; using UnityEditor; using UnityEngine; @@ -5,6 +6,48 @@ using UnityEngine.UI; public static class MyUIUtil { + [MenuItem("Tools/Safe Rename Files (Space → Underscore)")] + public static void RenameFilesInSelectedFolder() + { + Object obj = Selection.activeObject; + if (obj == null) + { + Debug.LogError("폴더를 선택하세요."); + return; + } + + string folderPath = AssetDatabase.GetAssetPath(obj); + + if (!Directory.Exists(folderPath)) + { + Debug.LogError("폴더만 선택 가능합니다."); + return; + } + + string[] guids = AssetDatabase.FindAssets("", new[] { folderPath }); + + foreach (var guid in guids) + { + string assetPath = AssetDatabase.GUIDToAssetPath(guid); + + if (assetPath.EndsWith(".meta")) + continue; + + string name = Path.GetFileName(assetPath); + if (!name.Contains(" ")) + continue; + + string newName = name.Replace(" ", "_"); + + AssetDatabase.RenameAsset(assetPath, Path.GetFileNameWithoutExtension(newName)); + Debug.Log($"변경: {name} → {newName}"); + } + + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + Debug.Log("완료!"); + } + static string path_whitebg = "Assets/ResWork/UI_Image/Common/whitebg.png"; static void SetLayerRecursively(GameObject obj, string newLayer = "UI")