You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.8 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// Static class for adding More Debug funtions
  6. /// </summary>
  7. public static class DebugExtensions
  8. {
  9. /// <summary>
  10. /// Draws wireframe cube in scene view
  11. /// </summary>
  12. /// <param name="Position">Centre of cube</param>
  13. /// <param name="Extent">extent of cube (half of size)</param>
  14. /// <param name="color">Color of lines</param>
  15. /// <param name="duration">Amount of time cube is displayed</param>
  16. /// <param name="depthTest">Should cube be obsured by otherobjects</param>
  17. public static void DrawCube(Vector3 Position, Vector3 Extent, Color color, float duration, bool depthTest = true)
  18. {
  19. Vector3 min = Position - Extent;
  20. Vector3 max = Position + Extent;
  21. //Draw bottom Square
  22. Debug.DrawLine(new Vector3(min.x, min.y, min.z), new Vector3(min.x, min.y, max.z), color, duration, depthTest);
  23. Debug.DrawLine(new Vector3(min.x, min.y, max.z), new Vector3(max.x, min.y, max.z), color, duration, depthTest);
  24. Debug.DrawLine(new Vector3(max.x, min.y, max.z), new Vector3(max.x, min.y, min.z), color, duration, depthTest);
  25. Debug.DrawLine(new Vector3(max.x, min.y, min.z), new Vector3(min.x, min.y, min.z), color, duration, depthTest);
  26. //top square
  27. Debug.DrawLine(new Vector3(min.x, max.y, min.z), new Vector3(min.x, max.y, max.z), color, duration, depthTest);
  28. Debug.DrawLine(new Vector3(min.x, max.y, max.z), new Vector3(max.x, max.y, max.z), color, duration, depthTest);
  29. Debug.DrawLine(new Vector3(max.x, max.y, max.z), new Vector3(max.x, max.y, min.z), color, duration, depthTest);
  30. Debug.DrawLine(new Vector3(max.x, max.y, min.z), new Vector3(min.x, max.y, min.z), color, duration, depthTest);
  31. //connect top and bottom
  32. Debug.DrawLine(new Vector3(min.x, min.y, min.z), new Vector3(min.x, max.y, min.z), color, duration, depthTest);
  33. Debug.DrawLine(new Vector3(min.x, min.y, max.z), new Vector3(min.x, max.y, max.z), color, duration, depthTest);
  34. Debug.DrawLine(new Vector3(max.x, min.y, max.z), new Vector3(max.x, max.y, max.z), color, duration, depthTest);
  35. Debug.DrawLine(new Vector3(max.x, min.y, min.z), new Vector3(max.x, max.y, min.z), color, duration, depthTest);
  36. }
  37. /// <summary>
  38. /// Draws wireframe cube in scene view
  39. /// </summary>
  40. /// <param name="Position">Centre of cube</param>
  41. /// <param name="Extent">extent of cube (half of size)</param>
  42. /// <param name="color">Color of lines</param>
  43. /// <param name="duration">Amount of time cube is displayed</param>
  44. public static void DrawCube(Vector3 Position, float Extent, Color color, float duration)
  45. {
  46. //Call overload funtion
  47. DrawCube(Position, Vector3.one * Extent, color, duration);
  48. }
  49. }//End DebugExtentions