Collidable.cs 600 B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. using System.Collections;
  3. public class Collidable : CompareXMonoBehaviour
  4. {
  5. Bounds _bounds;
  6. int _lastRectTickCalculation;
  7. BoxCollider _boxCollider;
  8. protected virtual void Awake()
  9. {
  10. _boxCollider = GetComponent<BoxCollider>();
  11. AVDebug.Assert(_boxCollider != null, "We need a box collider on this "+name+" in order to be able to extract bounds for collisions");
  12. }
  13. public Bounds GetBounds()
  14. {
  15. if (RecordingManager.Ticks != _lastRectTickCalculation)
  16. {
  17. _bounds = _boxCollider.bounds;
  18. _lastRectTickCalculation = RecordingManager.Ticks;
  19. }
  20. return _bounds;
  21. }
  22. }