|
@ -7,7 +7,7 @@ using UnityEngine; |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public static class DebugExtensions |
|
|
public static class DebugExtensions |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Draws wireframe cube in scene view
|
|
|
/// Draws wireframe cube in scene view
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -16,34 +16,40 @@ public static class DebugExtensions |
|
|
/// <param name="color">Color of lines</param>
|
|
|
/// <param name="color">Color of lines</param>
|
|
|
/// <param name="duration">Amount of time cube is displayed</param>
|
|
|
/// <param name="duration">Amount of time cube is displayed</param>
|
|
|
/// <param name="depthTest">Should cube be obsured by otherobjects</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) |
|
|
|
|
|
|
|
|
public static void DrawCube(Vector3 Position, Vector3 Extent, Color color, float duration, bool depthTest = true, bool isGizmo = false) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
Vector3 min = Position - Extent; |
|
|
Vector3 min = Position - Extent; |
|
|
Vector3 max = Position + Extent; |
|
|
Vector3 max = Position + Extent; |
|
|
|
|
|
|
|
|
Color oldColor = Gizmos.color; |
|
|
|
|
|
Gizmos.color = color; |
|
|
|
|
|
Gizmos.DrawWireCube(Position, Extent * 2); |
|
|
|
|
|
Gizmos.color = oldColor; |
|
|
|
|
|
|
|
|
if (isGizmo) |
|
|
|
|
|
{ |
|
|
|
|
|
Color oldColor = Gizmos.color; |
|
|
|
|
|
Gizmos.color = color; |
|
|
|
|
|
Gizmos.DrawWireCube(Position, Extent * 2); |
|
|
|
|
|
Gizmos.color = oldColor; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Draw bottom Square
|
|
|
//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);
|
|
|
|
|
|
|
|
|
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>
|
|
|
/// <summary>
|
|
@ -53,10 +59,10 @@ public static class DebugExtensions |
|
|
/// <param name="Extent">extent of cube (half of size)</param>
|
|
|
/// <param name="Extent">extent of cube (half of size)</param>
|
|
|
/// <param name="color">Color of lines</param>
|
|
|
/// <param name="color">Color of lines</param>
|
|
|
/// <param name="duration">Amount of time cube is displayed</param>
|
|
|
/// <param name="duration">Amount of time cube is displayed</param>
|
|
|
public static void DrawCube(Vector3 Position, float Extent, Color color, float duration) |
|
|
|
|
|
|
|
|
public static void DrawCube(Vector3 Position, float Extent, Color color, float duration, bool isGizmo = false) |
|
|
{ |
|
|
{ |
|
|
//Call overload funtion
|
|
|
//Call overload funtion
|
|
|
DrawCube(Position, Vector3.one * Extent, color, duration); |
|
|
|
|
|
|
|
|
DrawCube(Position, Vector3.one * Extent, color, duration,false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -89,7 +95,7 @@ public static class DebugExtensions |
|
|
DrawRect(rect, color, duration, depthTest); |
|
|
DrawRect(rect, color, duration, depthTest); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}//End DebugExtentions
|
|
|
}//End DebugExtentions
|