TestBox.cs 522 B

123456789101112131415161718
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class TestBox : MonoBehaviour
  5. {
  6. private void Start()
  7. {
  8. Bounds bounds = GetAllBounds.GetRendererBounds(gameObject);
  9. GameObject obj = new GameObject("Test");
  10. obj.transform.position = bounds.center;
  11. obj.AddComponent<BoxCollider>().size = bounds.size;
  12. // GetComponent<BoxCollider>().center = bounds.center - transform.position;
  13. GetComponent<BoxCollider>().size = bounds.size;
  14. }
  15. }