|
|
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- /// <summary>
- /// Static class for adding More Debug funtions
- /// </summary>
- public static class DebugExtensions
- {
-
- /// <summary>
- /// Draws wireframe cube in scene view
- /// </summary>
- /// <param name="Position">Centre of cube</param>
- /// <param name="Extent">extent of cube (half of size)</param>
- /// <param name="color">Color of lines</param>
- /// <param name="duration">Amount of time cube is displayed</param>
- /// <param name="depthTest">Should cube be obsured by otherobjects</param>
- public static void DrawCube(Vector3 Position, Vector3 Extent, Color color, float duration, bool depthTest = true)
- {
-
- Vector3 min = Position - Extent;
- Vector3 max = Position + Extent;
-
- //Draw bottom Square
- Debug.DrawLine(new Vector3(min.x, min.y, min.z), new Vector3(min.x, min.y, max.z), color, duration, depthTest);
- Debug.DrawLine(new Vector3(min.x, min.y, max.z), new Vector3(max.x, min.y, max.z), color, duration, depthTest);
- Debug.DrawLine(new Vector3(max.x, min.y, max.z), new Vector3(max.x, min.y, min.z), color, duration, depthTest);
- Debug.DrawLine(new Vector3(max.x, min.y, min.z), new Vector3(min.x, min.y, min.z), color, duration, depthTest);
-
- //top square
- Debug.DrawLine(new Vector3(min.x, max.y, min.z), new Vector3(min.x, max.y, max.z), color, duration, depthTest);
- Debug.DrawLine(new Vector3(min.x, max.y, max.z), new Vector3(max.x, max.y, max.z), color, duration, depthTest);
- Debug.DrawLine(new Vector3(max.x, max.y, max.z), new Vector3(max.x, max.y, min.z), color, duration, depthTest);
- Debug.DrawLine(new Vector3(max.x, max.y, min.z), new Vector3(min.x, max.y, min.z), color, duration, depthTest);
-
- //connect top and bottom
- Debug.DrawLine(new Vector3(min.x, min.y, min.z), new Vector3(min.x, max.y, min.z), color, duration, depthTest);
- Debug.DrawLine(new Vector3(min.x, min.y, max.z), new Vector3(min.x, max.y, max.z), color, duration, depthTest);
- Debug.DrawLine(new Vector3(max.x, min.y, max.z), new Vector3(max.x, max.y, max.z), color, duration, depthTest);
- Debug.DrawLine(new Vector3(max.x, min.y, min.z), new Vector3(max.x, max.y, min.z), color, duration, depthTest);
- }
-
- /// <summary>
- /// Draws wireframe cube in scene view
- /// </summary>
- /// <param name="Position">Centre of cube</param>
- /// <param name="Extent">extent of cube (half of size)</param>
- /// <param name="color">Color of lines</param>
- /// <param name="duration">Amount of time cube is displayed</param>
- public static void DrawCube(Vector3 Position, float Extent, Color color, float duration)
- {
- //Call overload funtion
- DrawCube(Position, Vector3.one * Extent, color, duration);
- }
-
- }//End DebugExtentions
|