unity 删除 组件 Components

using UnityEngine;

using System.Collections;

using UnityEditor;

public class RemoveComponents

{

[MenuItem("Tools/Remove MeshCollider")]

public static void RemoveMeshCollider()

{

GameObject[] colliders = Selection.gameObjects;

for (int i = 0; i < colliders.Length; i++)

{

MeshCollider mc = colliders[i].GetComponent();

if (mc)

{

GameObject.DestroyImmediate(mc);

}

}

Debug.Log("Remove MeshColliders complete!");

}

[MenuItem("Tools/Remove Animator")]

public static void RemoveAnimator()

{

GameObject[] colliders = Selection.gameObjects;

for (int i = 0; i < colliders.Length; i++)

{

Animator mc = colliders[i].GetComponent();

if (mc)

{

GameObject.DestroyImmediate(mc);

}

}

Debug.Log("Remove Animators complete!");

}

}

你可能感兴趣的:(unity 删除 组件 Components)