MeshColliderCreator.cs 1000 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. using System.Collections;
  3. #if UNITY_EDITOR
  4. [ExecuteInEditMode()]
  5. #endif
  6. public class MeshColliderCreator : MonoBehaviour {
  7. // Automatically add mesh colliders to all child meshes
  8. // TODO: actually remove this file
  9. // Properties
  10. public bool actOnChildren;
  11. // ================================================================================================================
  12. // MAIN EVENT INTERFACE -------------------------------------------------------------------------------------------
  13. #if UNITY_EDITOR
  14. void Start () {
  15. createColliders();
  16. }
  17. void Update() {
  18. if (!Application.isPlaying) createColliders();
  19. }
  20. #endif
  21. // ================================================================================================================
  22. // INTERNAL INTERFACE ---------------------------------------------------------------------------------------------
  23. private void createColliders() {
  24. GameObjectUtils.createMeshColliders(gameObject, actOnChildren);
  25. }
  26. }