using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; public class SelecyionTest : Editor { [MenuItem("Test/Des")] public static void Test() { Transform[] transforms = Selection.transforms; for (int i = 0; i < transforms.Length; i++) { Debug.Log(transforms[i].name); foreach (var item in transforms[i].GetComponentsInChildren()) { DestroyImmediate(item); } foreach (var item in transforms[i].GetComponentsInChildren()) { DestroyImmediate(item); } } } [MenuItem("Test/Add")] public static void addname() { Transform[] transforms = Selection.transforms; for (int i = 0; i < transforms.Length; i++) { foreach (var item in transforms[i].GetComponentsInChildren(true)) { item.name = item.name + "1"; } } } }