| using UnityEngine;  | 
| using UnityEditor;  | 
|   | 
|   | 
| public class RenameTool : EditorWindow  | 
| {  | 
|     [UnityEditor.MenuItem("美术工具/资源重命名")]  | 
|     static void Init()  | 
|     {  | 
|         window = GetWindow(typeof(RenameTool), true, "资源重命名工具") as RenameTool;  | 
|         window.position = new Rect(UnityEngine.Screen.width / 2, UnityEngine.Screen.height / 2, 300, 300);  | 
|         window.Show();  | 
|     }  | 
|   | 
|     private static RenameTool window = null;  | 
|     private static string _srcLetter = "";  | 
|     private static string _destLetter = "";  | 
|     private void OnGUI()  | 
|     {  | 
|         GUILayout.BeginVertical();  | 
|   | 
|         GUILayout.Box(new GUIContent("美术重命名工具:"));  | 
|         GUILayout.Label("要替换的字母:");  | 
|         _srcLetter = GUILayout.TextField(_srcLetter);  | 
|         GUILayout.Label("替换成最终的字母:");  | 
|         _destLetter = GUILayout.TextField(_destLetter);  | 
|   | 
|   | 
|         GUILayout.FlexibleSpace();  | 
|   | 
|   | 
|         GUILayout.BeginHorizontal();  | 
|         if (GUILayout.Button("重命名")) {  | 
|             UnityEngine.Object[] objects = Selection.GetFiltered(typeof(System.Object), UnityEditor.SelectionMode.DeepAssets);  | 
|             for (int i = 0; i < objects.Length; ++i) {  | 
|                 UnityEngine.Object srcObj = objects[i];  | 
|   | 
|                 string srcObjName = objects[i].name;  | 
|                 if (srcObjName.Contains(_srcLetter)) {  | 
|                     srcObjName = srcObjName.Replace(_srcLetter, _destLetter);  | 
|                     objects[i].name = srcObjName;  | 
|                     string path = AssetDatabase.GetAssetPath(srcObj);  | 
|                     AssetDatabase.RenameAsset(path, srcObjName);  | 
|                 }  | 
|             }  | 
|             AssetDatabase.SaveAssets();  | 
|             AssetDatabase.Refresh();  | 
|         }  | 
|         GUILayout.EndHorizontal();  | 
|   | 
|         GUILayout.EndVertical();  | 
|     }  | 
| }  | 
|   |