using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// Static class for adding More Debug funtions /// public static class DebugExtensions { /// /// Draws wireframe cube in scene view /// /// Centre of cube /// extent of cube (half of size) /// Color of lines /// Amount of time cube is displayed /// Should cube be obsured by otherobjects 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); } /// /// Draws wireframe cube in scene view /// /// Centre of cube /// extent of cube (half of size) /// Color of lines /// Amount of time cube is displayed public static void DrawCube(Vector3 Position, float Extent, Color color, float duration) { //Call overload funtion DrawCube(Position, Vector3.one * Extent, color, duration); } /// /// Draws wireframe around a RectTransform in scene view /// /// Rect transform to draw around /// Color of the lines /// How long the lines should be visible for /// Should the lines be obscured by objects closer to the camera public static void DrawRect(RectTransform transform, Color color, float duration = 0.0f, bool depthTest = false) { Rect rect = transform.GlobalRect(); Debug.DrawLine(new Vector3(rect.min.x, rect.max.y, 0), new Vector3(rect.max.x, rect.max.y, 0), color, duration, depthTest); Debug.DrawLine(new Vector3(rect.max.x, rect.max.y, 0), new Vector3(rect.max.x, rect.min.y, 0), color, duration, depthTest); Debug.DrawLine(new Vector3(rect.max.x, rect.min.y, 0), new Vector3(rect.min.x, rect.min.y, 0), color, duration, depthTest); Debug.DrawLine(new Vector3(rect.min.x, rect.min.y, 0), new Vector3(rect.min.x, rect.max.y, 0), color, duration, depthTest); } }//End DebugExtentions