DisableBoxCollider.cs 991 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using UnityEditor;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Text;
  8. /// <summary>
  9. /// 禁用DisableBoxCollider
  10. /// </summary>
  11. public class DisableBoxCollider
  12. {
  13. /// <summary>
  14. /// 资源包后缀
  15. /// </summary>
  16. private static string AssetBundleURE = ".unity3d";
  17. /// <summary>
  18. /// 禁用BoxCollider
  19. /// </summary>
  20. [MenuItem("Tools/DisableBoxCollider")]
  21. private static void DisableBoxColliderFun()
  22. {
  23. GameObject obj = Selection.activeObject as GameObject;
  24. if (obj == null)
  25. {
  26. Debug.LogError("未选中任何物体!!!");
  27. return;
  28. }
  29. BoxCollider[] bcs = obj.GetComponentsInChildren<BoxCollider>(true);
  30. for (int i = 0; i < bcs.Length; i++)
  31. {
  32. bcs[i].enabled = false;
  33. // MonoBehaviour.DestroyImmediate(bcs[i]);
  34. }
  35. AssetDatabase.SaveAssets();
  36. }
  37. }