ExtensionCollider.cs 479 B

123456789101112131415161718192021
  1. using UnityEngine;
  2. using System.Collections;
  3. public static class ExtensionCollider
  4. {
  5. public static void SetCollider(this Component comp, bool active)
  6. {
  7. BoxCollider2D collider = comp.GetComponent<BoxCollider2D>();
  8. if (collider)
  9. {
  10. collider.enabled = active;
  11. }
  12. }
  13. public static void SetCollider(this GameObject gameObject, bool active)
  14. {
  15. gameObject.GetComponent<BoxCollider2D>().enabled = active;
  16. }
  17. }