DebugDraw.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using UnityEngine;
  2. namespace DunGen
  3. {
  4. public static class DebugDraw
  5. {
  6. public static void Bounds(Bounds localBounds, Matrix4x4 transform, Color colour, float duration = 0f, bool depthTest = false)
  7. {
  8. Vector3 localMin = localBounds.min;
  9. Vector3 localMax = localBounds.max;
  10. Vector3 lut = transform.MultiplyPoint(new Vector3(localMin.x, localMax.y, localMax.z));
  11. Vector3 lub = transform.MultiplyPoint(new Vector3(localMin.x, localMax.y, localMin.z));
  12. Vector3 rut = transform.MultiplyPoint(new Vector3(localMax.x, localMax.y, localMax.z));
  13. Vector3 rub = transform.MultiplyPoint(new Vector3(localMax.x, localMax.y, localMin.z));
  14. Vector3 ldt = transform.MultiplyPoint(new Vector3(localMin.x, localMin.y, localMax.z));
  15. Vector3 ldb = transform.MultiplyPoint(new Vector3(localMin.x, localMin.y, localMin.z));
  16. Vector3 rdt = transform.MultiplyPoint(new Vector3(localMax.x, localMin.y, localMax.z));
  17. Vector3 rdb = transform.MultiplyPoint(new Vector3(localMax.x, localMin.y, localMin.z));
  18. // Top Face
  19. Debug.DrawLine(lut, lub, colour, duration, depthTest);
  20. Debug.DrawLine(lut, rut, colour, duration, depthTest);
  21. Debug.DrawLine(lub, rub, colour, duration, depthTest);
  22. Debug.DrawLine(rut, rub, colour, duration, depthTest);
  23. // Bottom Face
  24. Debug.DrawLine(ldt, ldb, colour, duration, depthTest);
  25. Debug.DrawLine(ldt, rdt, colour, duration, depthTest);
  26. Debug.DrawLine(ldb, rdb, colour, duration, depthTest);
  27. Debug.DrawLine(rdt, rdb, colour, duration, depthTest);
  28. // Connecting Lines
  29. Debug.DrawLine(lut, ldt, colour, duration, depthTest);
  30. Debug.DrawLine(rut, rdt, colour, duration, depthTest);
  31. Debug.DrawLine(rub, rdb, colour, duration, depthTest);
  32. Debug.DrawLine(lub, ldb, colour, duration, depthTest);
  33. }
  34. }
  35. }