#if UNITY_EDITOR using System.Collections.Generic; using UnityEngine; namespace Unity.XR.CoreUtils { /// /// Helpers for drawing shapes for debugging purposes. /// public static class DebugDraw { /// /// Draws a line around a polygonal shape. /// /// Polygon made of a series of adjacent points in world space. /// Color of the line. /// How long the line should be visible for. public static void Polygon(List vertices, Color color, float duration = 10f) { var vertexCount = vertices.Count; if (vertexCount < 2) return; var lengthMinusOne = vertexCount - 1; for (var i = 0; i < lengthMinusOne; i++) { var a = vertices[i]; var b = vertices[i + 1]; Debug.DrawLine(a, b, color, duration); } var last = vertices[lengthMinusOne]; var first = vertices[0]; Debug.DrawLine(last, first, color, duration); } /// /// Draws a line following a set of points. /// /// Connects the points in in order and closes the polygon /// by connecting the last point to the first. /// Polygon made of a series of adjacent points in world space. /// Color of the line. /// How long the line should be visible for. public static void Polygon(Vector3[] vertices, Color color, float duration = 10f) { var vertexCount = vertices.Length; if (vertexCount < 2) return; var lengthMinusOne = vertexCount - 1; for (var i = 0; i < lengthMinusOne; i++) { var a = vertices[i]; var b = vertices[i + 1]; Debug.DrawLine(a, b, color, duration); } var last = vertices[lengthMinusOne]; var first = vertices[0]; Debug.DrawLine(last, first, color, duration); } } } #endif