public class Editor_Selection
{
[MenuItem(
"EditTools/selection1")]
static void SelectionObj()
{
if (Selection.activeGameObject !=
null)
Debug.LogError(
"选中~" + Selection.activeGameObject.name);
Debug.LogError(
"选中的个数~" + Selection.objects.Length);
}
[MenuItem(
"GameObject/AddRigidbodyTest _#%F",
false,
12)]
static void SelectionAddComponent()
{
foreach (GameObject go
in Selection.gameObjects)
{
if (go.GetComponents<Rigidbody>().Length ==
0)
{
go.AddComponent<Rigidbody>();
Debug.LogError(
"go.name="+go.name);
}
}
}
[MenuItem(
"GameObject/DeleleMyTest",
false,
12)]
static void SelectionDelete()
{
foreach (Object item
in Selection.objects)
{
Undo.DestroyObjectImmediate(item);
}
}
[MenuItem(
"GameObject/DeleleMyTest",
true,
12)]
static bool myValidateData()
{
if (Selection.objects.Length >
0)
return true;
else
return false;
}
}