Advertisement
DeathDev

Untitled

Dec 30th, 2015
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public static class DebugDraw {
  6.  
  7.     public static void DrawRadius(Vector2 p, float r, int sides, Color c)
  8.     {
  9.         List<Vector2> verts = new List<Vector2>();
  10.  
  11.         for (int i = 0; i <= sides; i++)
  12.         {
  13.             verts.Add(p + new Vector2(Mathf.Cos(i / (float)sides * 2 * Mathf.PI), Mathf.Sin(i / (float)sides * 2 * Mathf.PI)) * r);
  14.             verts.Add(p + new Vector2(Mathf.Cos((i + 1) / (float)sides * 2 * Mathf.PI), Mathf.Sin((i + 1) / (float)sides * 2 * Mathf.PI)) * r);
  15.         }
  16.  
  17.         for(int i = 0; i < verts.Count; i++)
  18.         {
  19.             if (i < verts.Count - 1)
  20.                 Debug.DrawLine(verts[i], verts[i + 1], c);
  21.             else
  22.                 Debug.DrawLine(verts[i], verts[0], c);
  23.         }
  24.     }
  25.     public static void DrawRadius(Vector2 p, float r, int sides) { DrawRadius(p, r, sides, Color.white); }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement