1118OPSSNew/Assets/Editor/SelecyionTest.cs

40 lines
1.0 KiB
C#

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<BoxCollider>())
{
DestroyImmediate(item);
}
foreach (var item in transforms[i].GetComponentsInChildren<MeshCollider>())
{
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<Transform>(true))
{
item.name = item.name + "1";
}
}
}
}