public class GameObjectReName : EditorWindow { private string inputName; [MenuItem("Tools/ArtTools/GameObject物体重命名 %#&B")] static void Init() { EditorWindow.GetWindow(typeof(GameObjectReName)); } private void OnGUI() { inputName = EditorGUILayout.TextField("命名前缀",inputName); if (GUILayout.Button("开始重命名")) { StartReName(); } } void StartReName() { if (inputName != null) { string indexName = "00"; string newName = null; foreach (var transform in Selection.transforms) { int index = transform.childCount;//获取子物体数量 for (int i = 0; i < index; i++) { if (i < 9) { indexName = "00"; }else if (i < 99) { indexName = "0"; } else { indexName = null; } newName = inputName + indexName + (i + 1); transform.GetChild(i).gameObject.name = newName; } } } } }
关卡物体重命名
最新推荐文章于 2024-08-31 14:48:17 发布