slimecing

a fighting game featuring slimes and swords
Log | Files | Refs | README

DebugExtension.cs (47044B)


      1 using UnityEngine;
      2 using System.Collections;
      3 using System.Reflection;
      4 
      5 /// <summary>
      6 /// Debug Extension
      7 /// 	- Static class that extends Unity's debugging functionallity.
      8 /// 	- Attempts to mimic Unity's existing debugging behaviour for ease-of-use.
      9 /// 	- Includes gizmo drawing methods for less memory-intensive debug visualization.
     10 /// </summary>
     11 
     12 public static class DebugExtension
     13 {
     14 	#region DebugDrawFunctions
     15 	
     16 	/// <summary>
     17 	/// 	- Debugs a point.
     18 	/// </summary>
     19 	/// <param name='position'>
     20 	/// 	- The point to debug.
     21 	/// </param>
     22 	/// <param name='color'>
     23 	/// 	- The color of the point.
     24 	/// </param>
     25 	/// <param name='scale'>
     26 	/// 	- The size of the point.
     27 	/// </param>
     28 	/// <param name='duration'>
     29 	/// 	- How long to draw the point.
     30 	/// </param>
     31 	/// <param name='depthTest'>
     32 	/// 	- Whether or not this point should be faded when behind other objects.
     33 	/// </param>
     34 	public static void DebugPoint(Vector3 position, Color color, float scale = 1.0f, float duration = 0, bool depthTest = true)
     35 	{
     36 		color = (color == default(Color)) ? Color.white : color;
     37 		
     38 		Debug.DrawRay(position+(Vector3.up*(scale*0.5f)), -Vector3.up*scale, color, duration, depthTest);
     39 		Debug.DrawRay(position+(Vector3.right*(scale*0.5f)), -Vector3.right*scale, color, duration, depthTest);
     40 		Debug.DrawRay(position+(Vector3.forward*(scale*0.5f)), -Vector3.forward*scale, color, duration, depthTest);
     41 	}
     42 	
     43 	/// <summary>
     44 	/// 	- Debugs a point.
     45 	/// </summary>
     46 	/// <param name='position'>
     47 	/// 	- The point to debug.
     48 	/// </param>
     49 	/// <param name='scale'>
     50 	/// 	- The size of the point.
     51 	/// </param>
     52 	/// <param name='duration'>
     53 	/// 	- How long to draw the point.
     54 	/// </param>
     55 	/// <param name='depthTest'>
     56 	/// 	- Whether or not this point should be faded when behind other objects.
     57 	/// </param>
     58 	public static void DebugPoint(Vector3 position, float scale = 1.0f, float duration = 0, bool depthTest = true)
     59 	{
     60 		DebugPoint(position, Color.white, scale, duration, depthTest);
     61 	}
     62 	
     63 	/// <summary>
     64 	/// 	- Debugs an axis-aligned bounding box.
     65 	/// </summary>
     66 	/// <param name='bounds'>
     67 	/// 	- The bounds to debug.
     68 	/// </param>
     69 	/// <param name='color'>
     70 	/// 	- The color of the bounds.
     71 	/// </param>
     72 	/// <param name='duration'>
     73 	/// 	- How long to draw the bounds.
     74 	/// </param>
     75 	/// <param name='depthTest'>
     76 	/// 	- Whether or not the bounds should be faded when behind other objects.
     77 	/// </param>
     78 	public static void DebugBounds(Bounds bounds, Color color, float duration = 0, bool depthTest = true)
     79 	{
     80 		Vector3 center = bounds.center;
     81 		
     82 		float x = bounds.extents.x;
     83 		float y = bounds.extents.y;
     84 		float z = bounds.extents.z;
     85 		
     86 		Vector3 ruf = center+new Vector3(x,y,z);
     87 		Vector3 rub = center+new Vector3(x,y,-z);
     88 		Vector3 luf = center+new Vector3(-x,y,z);
     89 		Vector3 lub = center+new Vector3(-x,y,-z);
     90 		
     91 		Vector3 rdf = center+new Vector3(x,-y,z);
     92 		Vector3 rdb = center+new Vector3(x,-y,-z);
     93 		Vector3 lfd = center+new Vector3(-x,-y,z);
     94 		Vector3 lbd = center+new Vector3(-x,-y,-z);
     95 		
     96 		Debug.DrawLine(ruf, luf, color, duration, depthTest);
     97 		Debug.DrawLine(ruf, rub, color, duration, depthTest);
     98 		Debug.DrawLine(luf, lub, color, duration, depthTest);
     99 		Debug.DrawLine(rub, lub, color, duration, depthTest);
    100 		
    101 		Debug.DrawLine(ruf, rdf, color, duration, depthTest);
    102 		Debug.DrawLine(rub, rdb, color, duration, depthTest);
    103 		Debug.DrawLine(luf, lfd, color, duration, depthTest);
    104 		Debug.DrawLine(lub, lbd, color, duration, depthTest);
    105 		
    106 		Debug.DrawLine(rdf, lfd, color, duration, depthTest);
    107 		Debug.DrawLine(rdf, rdb, color, duration, depthTest);
    108 		Debug.DrawLine(lfd, lbd, color, duration, depthTest);
    109 		Debug.DrawLine(lbd, rdb, color, duration, depthTest);
    110 	}
    111 	
    112 	/// <summary>
    113 	/// 	- Debugs an axis-aligned bounding box.
    114 	/// </summary>
    115 	/// <param name='bounds'>
    116 	/// 	- The bounds to debug.
    117 	/// </param>
    118 	/// <param name='duration'>
    119 	/// 	- How long to draw the bounds.
    120 	/// </param>
    121 	/// <param name='depthTest'>
    122 	/// 	- Whether or not the bounds should be faded when behind other objects.
    123 	/// </param>
    124 	public static void DebugBounds(Bounds bounds, float duration = 0, bool depthTest = true)
    125 	{
    126 		DebugBounds(bounds, Color.white, duration, depthTest);
    127 	}
    128 	
    129 	/// <summary>
    130 	/// 	- Debugs a local cube.
    131 	/// </summary>
    132 	/// <param name='transform'>
    133 	/// 	- The transform that the cube will be local to.
    134 	/// </param>
    135 	/// <param name='size'>
    136 	/// 	- The size of the cube.
    137 	/// </param>
    138 	/// <param name='color'>
    139 	/// 	- Color of the cube.
    140 	/// </param>
    141 	/// <param name='center'>
    142 	/// 	- The position (relative to transform) where the cube will be debugged.
    143 	/// </param>
    144 	/// <param name='duration'>
    145 	/// 	- How long to draw the cube.
    146 	/// </param>
    147 	/// <param name='depthTest'>
    148 	/// 	- Whether or not the cube should be faded when behind other objects.
    149 	/// </param>
    150 	public static void DebugLocalCube(Transform transform, Vector3 size, Color color, Vector3 center = default(Vector3), float duration = 0, bool depthTest = true)
    151 	{
    152 		Vector3 lbb = transform.TransformPoint(center+((-size)*0.5f));
    153 		Vector3 rbb = transform.TransformPoint(center+(new Vector3(size.x, -size.y, -size.z)*0.5f));
    154 		
    155 		Vector3 lbf = transform.TransformPoint(center+(new Vector3(size.x, -size.y, size.z)*0.5f));
    156 		Vector3 rbf = transform.TransformPoint(center+(new Vector3(-size.x, -size.y, size.z)*0.5f));
    157 		
    158 		Vector3 lub = transform.TransformPoint(center+(new Vector3(-size.x, size.y, -size.z)*0.5f));
    159 		Vector3 rub = transform.TransformPoint(center+(new Vector3(size.x, size.y, -size.z)*0.5f));
    160 		
    161 		Vector3 luf = transform.TransformPoint(center+((size)*0.5f));
    162 		Vector3 ruf = transform.TransformPoint(center+(new Vector3(-size.x, size.y, size.z)*0.5f));
    163 		
    164 		Debug.DrawLine(lbb, rbb, color, duration, depthTest);
    165 		Debug.DrawLine(rbb, lbf, color, duration, depthTest);
    166 		Debug.DrawLine(lbf, rbf, color, duration, depthTest);
    167 		Debug.DrawLine(rbf, lbb, color, duration, depthTest);
    168 		
    169 		Debug.DrawLine(lub, rub, color, duration, depthTest);
    170 		Debug.DrawLine(rub, luf, color, duration, depthTest);
    171 		Debug.DrawLine(luf, ruf, color, duration, depthTest);
    172 		Debug.DrawLine(ruf, lub, color, duration, depthTest);
    173 		
    174 		Debug.DrawLine(lbb, lub, color, duration, depthTest);
    175 		Debug.DrawLine(rbb, rub, color, duration, depthTest);
    176 		Debug.DrawLine(lbf, luf, color, duration, depthTest);
    177 		Debug.DrawLine(rbf, ruf, color, duration, depthTest);
    178 	}
    179 	
    180 	/// <summary>
    181 	/// 	- Debugs a local cube.
    182 	/// </summary>
    183 	/// <param name='transform'>
    184 	/// 	- The transform that the cube will be local to.
    185 	/// </param>
    186 	/// <param name='size'>
    187 	/// 	- The size of the cube.
    188 	/// </param>
    189 	/// <param name='center'>
    190 	/// 	- The position (relative to transform) where the cube will be debugged.
    191 	/// </param>
    192 	/// <param name='duration'>
    193 	/// 	- How long to draw the cube.
    194 	/// </param>
    195 	/// <param name='depthTest'>
    196 	/// 	- Whether or not the cube should be faded when behind other objects.
    197 	/// </param>
    198 	public static void DebugLocalCube(Transform transform, Vector3 size, Vector3 center = default(Vector3), float duration = 0, bool depthTest = true)
    199 	{
    200 		DebugLocalCube(transform, size, Color.white, center, duration, depthTest);
    201 	}
    202 	
    203 	/// <summary>
    204 	/// 	- Debugs a local cube.
    205 	/// </summary>
    206 	/// <param name='space'>
    207 	/// 	- The space the cube will be local to.
    208 	/// </param>
    209 	/// <param name='size'>
    210 	///		- The size of the cube.
    211 	/// </param>
    212 	/// <param name='color'>
    213 	/// 	- Color of the cube.
    214 	/// </param>
    215 	/// <param name='center'>
    216 	/// 	- The position (relative to transform) where the cube will be debugged.
    217 	/// </param>
    218 	/// <param name='duration'>
    219 	/// 	- How long to draw the cube.
    220 	/// </param>
    221 	/// <param name='depthTest'>
    222 	/// 	- Whether or not the cube should be faded when behind other objects.
    223 	/// </param>
    224 	public static void DebugLocalCube(Matrix4x4 space, Vector3 size, Color color, Vector3 center = default(Vector3), float duration = 0, bool depthTest = true)
    225 	{	
    226 		color = (color == default(Color)) ? Color.white : color;
    227 		
    228 		Vector3 lbb = space.MultiplyPoint3x4(center+((-size)*0.5f));
    229 		Vector3 rbb = space.MultiplyPoint3x4(center+(new Vector3(size.x, -size.y, -size.z)*0.5f));
    230 		
    231 		Vector3 lbf = space.MultiplyPoint3x4(center+(new Vector3(size.x, -size.y, size.z)*0.5f));
    232 		Vector3 rbf = space.MultiplyPoint3x4(center+(new Vector3(-size.x, -size.y, size.z)*0.5f));
    233 		
    234 		Vector3 lub = space.MultiplyPoint3x4(center+(new Vector3(-size.x, size.y, -size.z)*0.5f));
    235 		Vector3 rub = space.MultiplyPoint3x4(center+(new Vector3(size.x, size.y, -size.z)*0.5f));
    236 		
    237 		Vector3 luf = space.MultiplyPoint3x4(center+((size)*0.5f));
    238 		Vector3 ruf = space.MultiplyPoint3x4(center+(new Vector3(-size.x, size.y, size.z)*0.5f));
    239 		
    240 		Debug.DrawLine(lbb, rbb, color, duration, depthTest);
    241 		Debug.DrawLine(rbb, lbf, color, duration, depthTest);
    242 		Debug.DrawLine(lbf, rbf, color, duration, depthTest);
    243 		Debug.DrawLine(rbf, lbb, color, duration, depthTest);
    244 		
    245 		Debug.DrawLine(lub, rub, color, duration, depthTest);
    246 		Debug.DrawLine(rub, luf, color, duration, depthTest);
    247 		Debug.DrawLine(luf, ruf, color, duration, depthTest);
    248 		Debug.DrawLine(ruf, lub, color, duration, depthTest);
    249 		
    250 		Debug.DrawLine(lbb, lub, color, duration, depthTest);
    251 		Debug.DrawLine(rbb, rub, color, duration, depthTest);
    252 		Debug.DrawLine(lbf, luf, color, duration, depthTest);
    253 		Debug.DrawLine(rbf, ruf, color, duration, depthTest);
    254 	}
    255 	
    256 	/// <summary>
    257 	/// 	- Debugs a local cube.
    258 	/// </summary>
    259 	/// <param name='space'>
    260 	/// 	- The space the cube will be local to.
    261 	/// </param>
    262 	/// <param name='size'>
    263 	///		- The size of the cube.
    264 	/// </param>
    265 	/// <param name='center'>
    266 	/// 	- The position (relative to transform) where the cube will be debugged.
    267 	/// </param>
    268 	/// <param name='duration'>
    269 	/// 	- How long to draw the cube.
    270 	/// </param>
    271 	/// <param name='depthTest'>
    272 	/// 	- Whether or not the cube should be faded when behind other objects.
    273 	/// </param>
    274 	public static void DebugLocalCube(Matrix4x4 space, Vector3 size, Vector3 center = default(Vector3), float duration = 0, bool depthTest = true)
    275 	{
    276 		DebugLocalCube(space, size, Color.white, center, duration, depthTest);
    277 	}
    278 	
    279 	/// <summary>
    280 	/// 	- Debugs a circle.
    281 	/// </summary>
    282 	/// <param name='position'>
    283 	/// 	- Where the center of the circle will be positioned.
    284 	/// </param>
    285 	/// <param name='up'>
    286 	/// 	- The direction perpendicular to the surface of the circle.
    287 	/// </param>
    288 	/// <param name='color'>
    289 	/// 	- The color of the circle.
    290 	/// </param>
    291 	/// <param name='radius'>
    292 	/// 	- The radius of the circle.
    293 	/// </param>
    294 	/// <param name='duration'>
    295 	/// 	- How long to draw the circle.
    296 	/// </param>
    297 	/// <param name='depthTest'>
    298 	/// 	- Whether or not the circle should be faded when behind other objects.
    299 	/// </param>
    300 	public static void DebugCircle(Vector3 position, Vector3 up, Color color, float radius = 1.0f, float duration = 0, bool depthTest = true)
    301 	{
    302 		Vector3 _up = up.normalized * radius;
    303 		Vector3 _forward = Vector3.Slerp(_up, -_up, 0.5f);
    304 		Vector3 _right = Vector3.Cross(_up, _forward).normalized*radius;
    305 		
    306 		Matrix4x4 matrix = new Matrix4x4();
    307 		
    308 		matrix[0] = _right.x;
    309 		matrix[1] = _right.y;
    310 		matrix[2] = _right.z;
    311 		
    312 		matrix[4] = _up.x;
    313 		matrix[5] = _up.y;
    314 		matrix[6] = _up.z;
    315 		
    316 		matrix[8] = _forward.x;
    317 		matrix[9] = _forward.y;
    318 		matrix[10] = _forward.z;
    319 		
    320 		Vector3 _lastPoint = position + matrix.MultiplyPoint3x4(new Vector3(Mathf.Cos(0), 0, Mathf.Sin(0)));
    321 		Vector3 _nextPoint = Vector3.zero;
    322 		
    323 		color = (color == default(Color)) ? Color.white : color;
    324 		
    325 		for(var i = 0; i < 91; i++){
    326 			_nextPoint.x = Mathf.Cos((i*4)*Mathf.Deg2Rad);
    327 			_nextPoint.z = Mathf.Sin((i*4)*Mathf.Deg2Rad);
    328 			_nextPoint.y = 0;
    329 			
    330 			_nextPoint = position + matrix.MultiplyPoint3x4(_nextPoint);
    331 			
    332 			Debug.DrawLine(_lastPoint, _nextPoint, color, duration, depthTest);
    333 			_lastPoint = _nextPoint;
    334 		}
    335 	}
    336 	
    337 	/// <summary>
    338 	/// 	- Debugs a circle.
    339 	/// </summary>
    340 	/// <param name='position'>
    341 	/// 	- Where the center of the circle will be positioned.
    342 	/// </param>
    343 	/// <param name='color'>
    344 	/// 	- The color of the circle.
    345 	/// </param>
    346 	/// <param name='radius'>
    347 	/// 	- The radius of the circle.
    348 	/// </param>
    349 	/// <param name='duration'>
    350 	/// 	- How long to draw the circle.
    351 	/// </param>
    352 	/// <param name='depthTest'>
    353 	/// 	- Whether or not the circle should be faded when behind other objects.
    354 	/// </param>
    355 	public static void DebugCircle(Vector3 position, Color color, float radius = 1.0f, float duration = 0, bool depthTest = true)
    356 	{
    357 		DebugCircle(position, Vector3.up, color, radius, duration, depthTest);
    358 	}
    359 	
    360 	/// <summary>
    361 	/// 	- Debugs a circle.
    362 	/// </summary>
    363 	/// <param name='position'>
    364 	/// 	- Where the center of the circle will be positioned.
    365 	/// </param>
    366 	/// <param name='up'>
    367 	/// 	- The direction perpendicular to the surface of the circle.
    368 	/// </param>
    369 	/// <param name='radius'>
    370 	/// 	- The radius of the circle.
    371 	/// </param>
    372 	/// <param name='duration'>
    373 	/// 	- How long to draw the circle.
    374 	/// </param>
    375 	/// <param name='depthTest'>
    376 	/// 	- Whether or not the circle should be faded when behind other objects.
    377 	/// </param>
    378 	public static void DebugCircle(Vector3 position, Vector3 up, float radius = 1.0f, float duration = 0, bool depthTest = true)
    379 	{
    380 		DebugCircle(position, up, Color.white, radius, duration, depthTest);
    381 	}
    382 	
    383 	/// <summary>
    384 	/// 	- Debugs a circle.
    385 	/// </summary>
    386 	/// <param name='position'>
    387 	/// 	- Where the center of the circle will be positioned.
    388 	/// </param>
    389 	/// <param name='radius'>
    390 	/// 	- The radius of the circle.
    391 	/// </param>
    392 	/// <param name='duration'>
    393 	/// 	- How long to draw the circle.
    394 	/// </param>
    395 	/// <param name='depthTest'>
    396 	/// 	- Whether or not the circle should be faded when behind other objects.
    397 	/// </param>
    398 	public static void DebugCircle(Vector3 position, float radius = 1.0f, float duration = 0, bool depthTest = true)
    399 	{
    400 		DebugCircle(position, Vector3.up, Color.white, radius, duration, depthTest);
    401 	}
    402 	
    403 	/// <summary>
    404 	/// 	- Debugs a wire sphere.
    405 	/// </summary>
    406 	/// <param name='position'>
    407 	/// 	- The position of the center of the sphere.
    408 	/// </param>
    409 	/// <param name='color'>
    410 	/// 	- The color of the sphere.
    411 	/// </param>
    412 	/// <param name='radius'>
    413 	/// 	- The radius of the sphere.
    414 	/// </param>
    415 	/// <param name='duration'>
    416 	/// 	- How long to draw the sphere.
    417 	/// </param>
    418 	/// <param name='depthTest'>
    419 	/// 	- Whether or not the sphere should be faded when behind other objects.
    420 	/// </param>
    421 	public static void DebugWireSphere(Vector3 position, Color color, float radius = 1.0f, float duration = 0, bool depthTest = true)
    422 	{
    423 		float angle = 10.0f;
    424 		
    425 		Vector3 x = new Vector3(position.x, position.y + radius * Mathf.Sin(0), position.z + radius * Mathf.Cos(0));
    426 		Vector3 y = new Vector3(position.x + radius * Mathf.Cos(0), position.y, position.z + radius * Mathf.Sin(0));
    427 		Vector3 z = new Vector3(position.x + radius * Mathf.Cos(0), position.y + radius * Mathf.Sin(0), position.z);
    428 		
    429 		Vector3 new_x;
    430 		Vector3 new_y;
    431 		Vector3 new_z;
    432 		
    433 		for(int i = 1; i < 37; i++){
    434 			
    435 			new_x = new Vector3(position.x, position.y + radius * Mathf.Sin(angle*i*Mathf.Deg2Rad), position.z + radius * Mathf.Cos(angle*i*Mathf.Deg2Rad));
    436 			new_y = new Vector3(position.x + radius * Mathf.Cos(angle*i*Mathf.Deg2Rad), position.y, position.z + radius * Mathf.Sin(angle*i*Mathf.Deg2Rad));
    437 			new_z = new Vector3(position.x + radius * Mathf.Cos(angle*i*Mathf.Deg2Rad), position.y + radius * Mathf.Sin(angle*i*Mathf.Deg2Rad), position.z);
    438 			
    439 			Debug.DrawLine(x, new_x, color, duration, depthTest);
    440 			Debug.DrawLine(y, new_y, color, duration, depthTest);
    441 			Debug.DrawLine(z, new_z, color, duration, depthTest);
    442 		
    443 			x = new_x;
    444 			y = new_y;
    445 			z = new_z;
    446 		}
    447 	}
    448 	
    449 	/// <summary>
    450 	/// 	- Debugs a wire sphere.
    451 	/// </summary>
    452 	/// <param name='position'>
    453 	/// 	- The position of the center of the sphere.
    454 	/// </param>
    455 	/// <param name='radius'>
    456 	/// 	- The radius of the sphere.
    457 	/// </param>
    458 	/// <param name='duration'>
    459 	/// 	- How long to draw the sphere.
    460 	/// </param>
    461 	/// <param name='depthTest'>
    462 	/// 	- Whether or not the sphere should be faded when behind other objects.
    463 	/// </param>
    464 	public static void DebugWireSphere(Vector3 position, float radius = 1.0f, float duration = 0, bool depthTest = true)
    465 	{
    466 		DebugWireSphere(position, Color.white, radius, duration, depthTest);
    467 	}
    468 	
    469 	/// <summary>
    470 	/// 	- Debugs a cylinder.
    471 	/// </summary>
    472 	/// <param name='start'>
    473 	/// 	- The position of one end of the cylinder.
    474 	/// </param>
    475 	/// <param name='end'>
    476 	/// 	- The position of the other end of the cylinder.
    477 	/// </param>
    478 	/// <param name='color'>
    479 	/// 	- The color of the cylinder.
    480 	/// </param>
    481 	/// <param name='radius'>
    482 	/// 	- The radius of the cylinder.
    483 	/// </param>
    484 	/// <param name='duration'>
    485 	/// 	- How long to draw the cylinder.
    486 	/// </param>
    487 	/// <param name='depthTest'>
    488 	/// 	- Whether or not the cylinder should be faded when behind other objects.
    489 	/// </param>
    490 	public static void DebugCylinder(Vector3 start, Vector3 end, Color color, float radius = 1, float duration = 0, bool depthTest = true)
    491 	{
    492 		Vector3 up = (end-start).normalized*radius;
    493 		Vector3 forward = Vector3.Slerp(up, -up, 0.5f);
    494 		Vector3 right = Vector3.Cross(up, forward).normalized*radius;
    495 		
    496 		//Radial circles
    497 		DebugExtension.DebugCircle(start, up, color, radius, duration, depthTest);	
    498 		DebugExtension.DebugCircle(end, -up, color, radius, duration, depthTest);
    499 		DebugExtension.DebugCircle((start+end)*0.5f, up, color, radius, duration, depthTest);
    500 		
    501 		//Side lines
    502 		Debug.DrawLine(start+right, end+right, color, duration, depthTest);
    503 		Debug.DrawLine(start-right, end-right, color, duration, depthTest);
    504 		
    505 		Debug.DrawLine(start+forward, end+forward, color, duration, depthTest);
    506 		Debug.DrawLine(start-forward, end-forward, color, duration, depthTest);
    507 		
    508 		//Start endcap
    509 		Debug.DrawLine(start-right, start+right, color, duration, depthTest);
    510 		Debug.DrawLine(start-forward, start+forward, color, duration, depthTest);
    511 		
    512 		//End endcap
    513 		Debug.DrawLine(end-right, end+right, color, duration, depthTest);
    514 		Debug.DrawLine(end-forward, end+forward, color, duration, depthTest);
    515 	}
    516 	
    517 	/// <summary>
    518 	/// 	- Debugs a cylinder.
    519 	/// </summary>
    520 	/// <param name='start'>
    521 	/// 	- The position of one end of the cylinder.
    522 	/// </param>
    523 	/// <param name='end'>
    524 	/// 	- The position of the other end of the cylinder.
    525 	/// </param>
    526 	/// <param name='radius'>
    527 	/// 	- The radius of the cylinder.
    528 	/// </param>
    529 	/// <param name='duration'>
    530 	/// 	- How long to draw the cylinder.
    531 	/// </param>
    532 	/// <param name='depthTest'>
    533 	/// 	- Whether or not the cylinder should be faded when behind other objects.
    534 	/// </param>
    535 	public static void DebugCylinder(Vector3 start, Vector3 end, float radius = 1, float duration = 0, bool depthTest = true)
    536 	{
    537 		DebugCylinder(start, end, Color.white, radius, duration, depthTest);
    538 	}
    539 	
    540 	/// <summary>
    541 	/// 	- Debugs a cone.
    542 	/// </summary>
    543 	/// <param name='position'>
    544 	/// 	- The position for the tip of the cone.
    545 	/// </param>
    546 	/// <param name='direction'>
    547 	/// 	- The direction for the cone gets wider in.
    548 	/// </param>
    549 	/// <param name='angle'>
    550 	/// 	- The angle of the cone.
    551 	/// </param>
    552 	/// <param name='color'>
    553 	/// 	- The color of the cone.
    554 	/// </param>
    555 	/// <param name='duration'>
    556 	/// 	- How long to draw the cone.
    557 	/// </param>
    558 	/// <param name='depthTest'>
    559 	/// 	- Whether or not the cone should be faded when behind other objects.
    560 	/// </param>
    561 	public static void DebugCone(Vector3 position, Vector3 direction, Color color, float angle = 45, float duration = 0, bool depthTest = true)
    562 	{
    563 		float length = direction.magnitude;
    564 		
    565 		Vector3 _forward = direction;
    566 		Vector3 _up = Vector3.Slerp(_forward, -_forward, 0.5f);
    567 		Vector3 _right = Vector3.Cross(_forward, _up).normalized*length;
    568 		
    569 		direction = direction.normalized;
    570 		
    571 		Vector3 slerpedVector = Vector3.Slerp(_forward, _up, angle/90.0f);
    572 		
    573 		float dist;
    574 		var farPlane = new Plane(-direction, position+_forward);
    575 		var distRay = new Ray(position, slerpedVector);
    576 	
    577 		farPlane.Raycast(distRay, out dist); 
    578 		
    579 		Debug.DrawRay(position, slerpedVector.normalized*dist, color);
    580 		Debug.DrawRay(position, Vector3.Slerp(_forward, -_up, angle/90.0f).normalized*dist, color, duration, depthTest);
    581 		Debug.DrawRay(position, Vector3.Slerp(_forward, _right, angle/90.0f).normalized*dist, color, duration, depthTest);
    582 		Debug.DrawRay(position, Vector3.Slerp(_forward, -_right, angle/90.0f).normalized*dist, color, duration, depthTest);
    583 		
    584 		DebugExtension.DebugCircle(position+_forward, direction, color, (_forward-(slerpedVector.normalized*dist)).magnitude, duration, depthTest);
    585 		DebugExtension.DebugCircle(position+(_forward*0.5f), direction, color, ((_forward*0.5f)-(slerpedVector.normalized*(dist*0.5f))).magnitude, duration, depthTest);
    586 	}
    587 	
    588 	/// <summary>
    589 	/// 	- Debugs a cone.
    590 	/// </summary>
    591 	/// <param name='position'>
    592 	/// 	- The position for the tip of the cone.
    593 	/// </param>
    594 	/// <param name='direction'>
    595 	/// 	- The direction for the cone gets wider in.
    596 	/// </param>
    597 	/// <param name='angle'>
    598 	/// 	- The angle of the cone.
    599 	/// </param>
    600 	/// <param name='duration'>
    601 	/// 	- How long to draw the cone.
    602 	/// </param>
    603 	/// <param name='depthTest'>
    604 	/// 	- Whether or not the cone should be faded when behind other objects.
    605 	/// </param>
    606 	public static void DebugCone(Vector3 position, Vector3 direction, float angle = 45, float duration = 0, bool depthTest = true)
    607 	{
    608 		DebugCone(position, direction, Color.white, angle, duration, depthTest);
    609 	}
    610 	
    611 	/// <summary>
    612 	/// 	- Debugs a cone.
    613 	/// </summary>
    614 	/// <param name='position'>
    615 	/// 	- The position for the tip of the cone.
    616 	/// </param>
    617 	/// <param name='angle'>
    618 	/// 	- The angle of the cone.
    619 	/// </param>
    620 	/// <param name='color'>
    621 	/// 	- The color of the cone.
    622 	/// </param>
    623 	/// <param name='duration'>
    624 	/// 	- How long to draw the cone.
    625 	/// </param>
    626 	/// <param name='depthTest'>
    627 	/// 	- Whether or not the cone should be faded when behind other objects.
    628 	/// </param>
    629 	public static void DebugCone(Vector3 position, Color color, float angle = 45, float duration = 0, bool depthTest = true)
    630 	{
    631 		DebugCone(position, Vector3.up, color, angle, duration, depthTest);
    632 	}
    633 	
    634 	/// <summary>
    635 	/// 	- Debugs a cone.
    636 	/// </summary>
    637 	/// <param name='position'>
    638 	/// 	- The position for the tip of the cone.
    639 	/// </param>
    640 	/// <param name='angle'>
    641 	/// 	- The angle of the cone.
    642 	/// </param>
    643 	/// <param name='duration'>
    644 	/// 	- How long to draw the cone.
    645 	/// </param>
    646 	/// <param name='depthTest'>
    647 	/// 	- Whether or not the cone should be faded when behind other objects.
    648 	/// </param>
    649 	public static void DebugCone(Vector3 position, float angle = 45, float duration = 0, bool depthTest = true)
    650 	{
    651 		DebugCone(position, Vector3.up, Color.white, angle, duration, depthTest);
    652 	}
    653 	
    654 	/// <summary>
    655 	/// 	- Debugs an arrow.
    656 	/// </summary>
    657 	/// <param name='position'>
    658 	/// 	- The start position of the arrow.
    659 	/// </param>
    660 	/// <param name='direction'>
    661 	/// 	- The direction the arrow will point in.
    662 	/// </param>
    663 	/// <param name='color'>
    664 	/// 	- The color of the arrow.
    665 	/// </param>
    666 	/// <param name='duration'>
    667 	/// 	- How long to draw the arrow.
    668 	/// </param>
    669 	/// <param name='depthTest'>
    670 	/// 	- Whether or not the arrow should be faded when behind other objects. 
    671 	/// </param>
    672 	public static void DebugArrow(Vector3 position, Vector3 direction, Color color, float duration = 0, bool depthTest = true)
    673 	{
    674 		Debug.DrawRay(position, direction, color, duration, depthTest);
    675 		DebugExtension.DebugCone(position+direction, -direction*0.333f, color, 15, duration, depthTest);
    676 	}
    677 	
    678 	/// <summary>
    679 	/// 	- Debugs an arrow.
    680 	/// </summary>
    681 	/// <param name='position'>
    682 	/// 	- The start position of the arrow.
    683 	/// </param>
    684 	/// <param name='direction'>
    685 	/// 	- The direction the arrow will point in.
    686 	/// </param>
    687 	/// <param name='duration'>
    688 	/// 	- How long to draw the arrow.
    689 	/// </param>
    690 	/// <param name='depthTest'>
    691 	/// 	- Whether or not the arrow should be faded when behind other objects. 
    692 	/// </param>
    693 	public static void DebugArrow(Vector3 position, Vector3 direction, float duration = 0, bool depthTest = true)
    694 	{
    695 		DebugArrow(position, direction, Color.white, duration, depthTest);
    696 	}
    697 	
    698 	/// <summary>
    699 	/// 	- Debugs a capsule.
    700 	/// </summary>
    701 	/// <param name='start'>
    702 	/// 	- The position of one end of the capsule.
    703 	/// </param>
    704 	/// <param name='end'>
    705 	/// 	- The position of the other end of the capsule.
    706 	/// </param>
    707 	/// <param name='color'>
    708 	/// 	- The color of the capsule.
    709 	/// </param>
    710 	/// <param name='radius'>
    711 	/// 	- The radius of the capsule.
    712 	/// </param>
    713 	/// <param name='duration'>
    714 	/// 	- How long to draw the capsule.
    715 	/// </param>
    716 	/// <param name='depthTest'>
    717 	/// 	- Whether or not the capsule should be faded when behind other objects.
    718 	/// </param>
    719 	public static void DebugCapsule(Vector3 start, Vector3 end, Color color, float radius = 1, float duration = 0, bool depthTest = true)
    720 	{
    721 		Vector3 up = (end-start).normalized*radius;
    722 		Vector3 forward = Vector3.Slerp(up, -up, 0.5f);
    723 		Vector3 right = Vector3.Cross(up, forward).normalized*radius;
    724 		
    725 		float height = (start-end).magnitude;
    726 		float sideLength = Mathf.Max(0, (height*0.5f)-radius);
    727 		Vector3 middle = (end+start)*0.5f;
    728 		
    729 		start = middle+((start-middle).normalized*sideLength);
    730 		end = middle+((end-middle).normalized*sideLength);
    731 		
    732 		//Radial circles
    733 		DebugExtension.DebugCircle(start, up, color, radius, duration, depthTest);	
    734 		DebugExtension.DebugCircle(end, -up, color, radius, duration, depthTest);
    735 		
    736 		//Side lines
    737 		Debug.DrawLine(start+right, end+right, color, duration, depthTest);
    738 		Debug.DrawLine(start-right, end-right, color, duration, depthTest);
    739 		
    740 		Debug.DrawLine(start+forward, end+forward, color, duration, depthTest);
    741 		Debug.DrawLine(start-forward, end-forward, color, duration, depthTest);
    742 		
    743 		for(int i = 1; i < 26; i++){
    744 			
    745 			//Start endcap
    746 			Debug.DrawLine(Vector3.Slerp(right, -up, i/25.0f)+start, Vector3.Slerp(right, -up, (i-1)/25.0f)+start, color, duration, depthTest);
    747 			Debug.DrawLine(Vector3.Slerp(-right, -up, i/25.0f)+start, Vector3.Slerp(-right, -up, (i-1)/25.0f)+start, color, duration, depthTest);
    748 			Debug.DrawLine(Vector3.Slerp(forward, -up, i/25.0f)+start, Vector3.Slerp(forward, -up, (i-1)/25.0f)+start, color, duration, depthTest);
    749 			Debug.DrawLine(Vector3.Slerp(-forward, -up, i/25.0f)+start, Vector3.Slerp(-forward, -up, (i-1)/25.0f)+start, color, duration, depthTest);
    750 			
    751 			//End endcap
    752 			Debug.DrawLine(Vector3.Slerp(right, up, i/25.0f)+end, Vector3.Slerp(right, up, (i-1)/25.0f)+end, color, duration, depthTest);
    753 			Debug.DrawLine(Vector3.Slerp(-right, up, i/25.0f)+end, Vector3.Slerp(-right, up, (i-1)/25.0f)+end, color, duration, depthTest);
    754 			Debug.DrawLine(Vector3.Slerp(forward, up, i/25.0f)+end, Vector3.Slerp(forward, up, (i-1)/25.0f)+end, color, duration, depthTest);
    755 			Debug.DrawLine(Vector3.Slerp(-forward, up, i/25.0f)+end, Vector3.Slerp(-forward, up, (i-1)/25.0f)+end, color, duration, depthTest);
    756 		}
    757 	}
    758 	
    759 	/// <summary>
    760 	/// 	- Debugs a capsule.
    761 	/// </summary>
    762 	/// <param name='start'>
    763 	/// 	- The position of one end of the capsule.
    764 	/// </param>
    765 	/// <param name='end'>
    766 	/// 	- The position of the other end of the capsule.
    767 	/// </param>
    768 	/// <param name='radius'>
    769 	/// 	- The radius of the capsule.
    770 	/// </param>
    771 	/// <param name='duration'>
    772 	/// 	- How long to draw the capsule.
    773 	/// </param>
    774 	/// <param name='depthTest'>
    775 	/// 	- Whether or not the capsule should be faded when behind other objects.
    776 	/// </param>
    777 	public static void DebugCapsule(Vector3 start, Vector3 end, float radius = 1, float duration = 0, bool depthTest = true)
    778 	{
    779 		DebugCapsule(start, end, Color.white, radius, duration, depthTest);	
    780 	}
    781 	
    782 	#endregion
    783 	
    784 	#region GizmoDrawFunctions
    785 	
    786 	/// <summary>
    787 	/// 	- Draws a point.
    788 	/// </summary>
    789 	/// <param name='position'>
    790 	/// 	- The point to draw.
    791 	/// </param>
    792 	///  <param name='color'>
    793 	/// 	- The color of the drawn point.
    794 	/// </param>
    795 	/// <param name='scale'>
    796 	/// 	- The size of the drawn point.
    797 	/// </param>
    798 	public static void DrawPoint(Vector3 position, Color color, float scale = 1.0f)
    799 	{
    800 		Color oldColor = Gizmos.color;
    801 		
    802 		Gizmos.color = color;		
    803 		Gizmos.DrawRay(position+(Vector3.up*(scale*0.5f)), -Vector3.up*scale);
    804 		Gizmos.DrawRay(position+(Vector3.right*(scale*0.5f)), -Vector3.right*scale);
    805 		Gizmos.DrawRay(position+(Vector3.forward*(scale*0.5f)), -Vector3.forward*scale);
    806 		
    807 		Gizmos.color = oldColor;
    808 	}
    809 	
    810 	/// <summary>
    811 	/// 	- Draws a point.
    812 	/// </summary>
    813 	/// <param name='position'>
    814 	/// 	- The point to draw.
    815 	/// </param>
    816 	/// <param name='scale'>
    817 	/// 	- The size of the drawn point.
    818 	/// </param>
    819 	public static void DrawPoint(Vector3 position, float scale = 1.0f)
    820 	{
    821 		DrawPoint(position, Color.white, scale);
    822 	}
    823 	
    824 	/// <summary>
    825 	/// 	- Draws an axis-aligned bounding box.
    826 	/// </summary>
    827 	/// <param name='bounds'>
    828 	/// 	- The bounds to draw.
    829 	/// </param>
    830 	/// <param name='color'>
    831 	/// 	- The color of the bounds.
    832 	/// </param>
    833 	public static void DrawBounds(Bounds bounds, Color color)
    834 	{
    835 		Vector3 center = bounds.center;
    836 		
    837 		float x = bounds.extents.x;
    838 		float y = bounds.extents.y;
    839 		float z = bounds.extents.z;
    840 		
    841 		Vector3 ruf = center+new Vector3(x,y,z);
    842 		Vector3 rub = center+new Vector3(x,y,-z);
    843 		Vector3 luf = center+new Vector3(-x,y,z);
    844 		Vector3 lub = center+new Vector3(-x,y,-z);
    845 		
    846 		Vector3 rdf = center+new Vector3(x,-y,z);
    847 		Vector3 rdb = center+new Vector3(x,-y,-z);
    848 		Vector3 lfd = center+new Vector3(-x,-y,z);
    849 		Vector3 lbd = center+new Vector3(-x,-y,-z);
    850 		
    851 		Color oldColor = Gizmos.color;
    852 		Gizmos.color = color;
    853 		
    854 		Gizmos.DrawLine(ruf, luf);
    855 		Gizmos.DrawLine(ruf, rub);
    856 		Gizmos.DrawLine(luf, lub);
    857 		Gizmos.DrawLine(rub, lub);
    858 		
    859 		Gizmos.DrawLine(ruf, rdf);
    860 		Gizmos.DrawLine(rub, rdb);
    861 		Gizmos.DrawLine(luf, lfd);
    862 		Gizmos.DrawLine(lub, lbd);
    863 		
    864 		Gizmos.DrawLine(rdf, lfd);
    865 		Gizmos.DrawLine(rdf, rdb);
    866 		Gizmos.DrawLine(lfd, lbd);
    867 		Gizmos.DrawLine(lbd, rdb);
    868 		
    869 		Gizmos.color = oldColor;
    870 	}
    871 	
    872 	/// <summary>
    873 	/// 	- Draws an axis-aligned bounding box.
    874 	/// </summary>
    875 	/// <param name='bounds'>
    876 	/// 	- The bounds to draw.
    877 	/// </param>
    878 	public static void DrawBounds(Bounds bounds)
    879 	{
    880 		DrawBounds(bounds, Color.white);
    881 	}
    882 	
    883 	/// <summary>
    884 	/// 	- Draws a local cube.
    885 	/// </summary>
    886 	/// <param name='transform'>
    887 	/// 	- The transform the cube will be local to.
    888 	/// </param>
    889 	/// <param name='size'>
    890 	/// 	- The local size of the cube.
    891 	/// </param>
    892 	/// <param name='center'>
    893 	///		- The local position of the cube.
    894 	/// </param>
    895 	/// <param name='color'>
    896 	/// 	- The color of the cube.
    897 	/// </param>
    898 	public static void DrawLocalCube(Transform transform, Vector3 size, Color color, Vector3 center = default(Vector3))
    899 	{
    900 		Color oldColor = Gizmos.color;
    901 		Gizmos.color = color;
    902 		
    903 		Vector3 lbb = transform.TransformPoint(center+((-size)*0.5f));
    904 		Vector3 rbb = transform.TransformPoint(center+(new Vector3(size.x, -size.y, -size.z)*0.5f));
    905 		
    906 		Vector3 lbf = transform.TransformPoint(center+(new Vector3(size.x, -size.y, size.z)*0.5f));
    907 		Vector3 rbf = transform.TransformPoint(center+(new Vector3(-size.x, -size.y, size.z)*0.5f));
    908 		
    909 		Vector3 lub = transform.TransformPoint(center+(new Vector3(-size.x, size.y, -size.z)*0.5f));
    910 		Vector3 rub = transform.TransformPoint(center+(new Vector3(size.x, size.y, -size.z)*0.5f));
    911 		
    912 		Vector3 luf = transform.TransformPoint(center+((size)*0.5f));
    913 		Vector3 ruf = transform.TransformPoint(center+(new Vector3(-size.x, size.y, size.z)*0.5f));
    914 		
    915 		Gizmos.DrawLine(lbb, rbb);
    916 		Gizmos.DrawLine(rbb, lbf);
    917 		Gizmos.DrawLine(lbf, rbf);
    918 		Gizmos.DrawLine(rbf, lbb);
    919 		
    920 		Gizmos.DrawLine(lub, rub);
    921 		Gizmos.DrawLine(rub, luf);
    922 		Gizmos.DrawLine(luf, ruf);
    923 		Gizmos.DrawLine(ruf, lub);
    924 		
    925 		Gizmos.DrawLine(lbb, lub);
    926 		Gizmos.DrawLine(rbb, rub);
    927 		Gizmos.DrawLine(lbf, luf);
    928 		Gizmos.DrawLine(rbf, ruf);
    929 		
    930 		Gizmos.color = oldColor;
    931 	}
    932 	
    933 	/// <summary>
    934 	/// 	- Draws a local cube.
    935 	/// </summary>
    936 	/// <param name='transform'>
    937 	/// 	- The transform the cube will be local to.
    938 	/// </param>
    939 	/// <param name='size'>
    940 	/// 	- The local size of the cube.
    941 	/// </param>
    942 	/// <param name='center'>
    943 	///		- The local position of the cube.
    944 	/// </param>	
    945 	public static void DrawLocalCube(Transform transform, Vector3 size, Vector3 center = default(Vector3))
    946 	{
    947 		DrawLocalCube(transform, size, Color.white, center);
    948 	}
    949 	
    950 	/// <summary>
    951 	/// 	- Draws a local cube.
    952 	/// </summary>
    953 	/// <param name='space'>
    954 	/// 	- The space the cube will be local to.
    955 	/// </param>
    956 	/// <param name='size'>
    957 	/// 	- The local size of the cube.
    958 	/// </param>
    959 	/// <param name='center'>
    960 	/// 	- The local position of the cube.
    961 	/// </param>
    962 	/// <param name='color'>
    963 	/// 	- The color of the cube.
    964 	/// </param>
    965 	public static void DrawLocalCube(Matrix4x4 space, Vector3 size, Color color, Vector3 center = default(Vector3))
    966 	{
    967 		Color oldColor = Gizmos.color;
    968 		Gizmos.color = color;
    969 		
    970 		Vector3 lbb = space.MultiplyPoint3x4(center+((-size)*0.5f));
    971 		Vector3 rbb = space.MultiplyPoint3x4(center+(new Vector3(size.x, -size.y, -size.z)*0.5f));
    972 		
    973 		Vector3 lbf = space.MultiplyPoint3x4(center+(new Vector3(size.x, -size.y, size.z)*0.5f));
    974 		Vector3 rbf = space.MultiplyPoint3x4(center+(new Vector3(-size.x, -size.y, size.z)*0.5f));
    975 		
    976 		Vector3 lub = space.MultiplyPoint3x4(center+(new Vector3(-size.x, size.y, -size.z)*0.5f));
    977 		Vector3 rub = space.MultiplyPoint3x4(center+(new Vector3(size.x, size.y, -size.z)*0.5f));
    978 		
    979 		Vector3 luf = space.MultiplyPoint3x4(center+((size)*0.5f));
    980 		Vector3 ruf = space.MultiplyPoint3x4(center+(new Vector3(-size.x, size.y, size.z)*0.5f));
    981 		
    982 		Gizmos.DrawLine(lbb, rbb);
    983 		Gizmos.DrawLine(rbb, lbf);
    984 		Gizmos.DrawLine(lbf, rbf);
    985 		Gizmos.DrawLine(rbf, lbb);
    986 		
    987 		Gizmos.DrawLine(lub, rub);
    988 		Gizmos.DrawLine(rub, luf);
    989 		Gizmos.DrawLine(luf, ruf);
    990 		Gizmos.DrawLine(ruf, lub);
    991 		
    992 		Gizmos.DrawLine(lbb, lub);
    993 		Gizmos.DrawLine(rbb, rub);
    994 		Gizmos.DrawLine(lbf, luf);
    995 		Gizmos.DrawLine(rbf, ruf);
    996 		
    997 		Gizmos.color = oldColor;
    998 	}
    999 	
   1000 	/// <summary>
   1001 	/// 	- Draws a local cube.
   1002 	/// </summary>
   1003 	/// <param name='space'>
   1004 	/// 	- The space the cube will be local to.
   1005 	/// </param>
   1006 	/// <param name='size'>
   1007 	/// 	- The local size of the cube.
   1008 	/// </param>
   1009 	/// <param name='center'>
   1010 	/// 	- The local position of the cube.
   1011 	/// </param>
   1012 	public static void DrawLocalCube(Matrix4x4 space, Vector3 size, Vector3 center = default(Vector3))
   1013 	{
   1014 		DrawLocalCube(space, size, Color.white, center);
   1015 	}
   1016 	
   1017 	/// <summary>
   1018 	/// 	- Draws a circle.
   1019 	/// </summary>
   1020 	/// <param name='position'>
   1021 	/// 	- Where the center of the circle will be positioned.
   1022 	/// </param>
   1023 	/// <param name='up'>
   1024 	/// 	- The direction perpendicular to the surface of the circle.
   1025 	/// </param>
   1026 	/// <param name='color'>
   1027 	/// 	- The color of the circle.
   1028 	/// </param>
   1029 	/// <param name='radius'>
   1030 	/// 	- The radius of the circle.
   1031 	/// </param>
   1032 	public static void DrawCircle(Vector3 position, Vector3 up, Color color, float radius = 1.0f)
   1033 	{
   1034 		up = ((up == Vector3.zero) ? Vector3.up : up).normalized * radius;
   1035 		Vector3 _forward = Vector3.Slerp(up, -up, 0.5f);
   1036 		Vector3 _right = Vector3.Cross(up, _forward).normalized*radius;
   1037 		
   1038 		Matrix4x4 matrix = new Matrix4x4();
   1039 		
   1040 		matrix[0] = _right.x;
   1041 		matrix[1] = _right.y;
   1042 		matrix[2] = _right.z;
   1043 		
   1044 		matrix[4] = up.x;
   1045 		matrix[5] = up.y;
   1046 		matrix[6] = up.z;
   1047 		
   1048 		matrix[8] = _forward.x;
   1049 		matrix[9] = _forward.y;
   1050 		matrix[10] = _forward.z;
   1051 		
   1052 		Vector3 _lastPoint = position + matrix.MultiplyPoint3x4(new Vector3(Mathf.Cos(0), 0, Mathf.Sin(0)));
   1053 		Vector3 _nextPoint = Vector3.zero;
   1054 		
   1055 		Color oldColor = Gizmos.color;
   1056 		Gizmos.color = (color == default(Color)) ? Color.white : color;
   1057 		
   1058 		for(var i = 0; i < 91; i++){
   1059 			_nextPoint.x = Mathf.Cos((i*4)*Mathf.Deg2Rad);
   1060 			_nextPoint.z = Mathf.Sin((i*4)*Mathf.Deg2Rad);
   1061 			_nextPoint.y = 0;
   1062 			
   1063 			_nextPoint = position + matrix.MultiplyPoint3x4(_nextPoint);
   1064 			
   1065 			Gizmos.DrawLine(_lastPoint, _nextPoint);
   1066 			_lastPoint = _nextPoint;
   1067 		}
   1068 		
   1069 		Gizmos.color = oldColor;
   1070 	}
   1071 	
   1072 	/// <summary>
   1073 	/// 	- Draws a circle.
   1074 	/// </summary>
   1075 	/// <param name='position'>
   1076 	/// 	- Where the center of the circle will be positioned.
   1077 	/// </param>
   1078 	/// <param name='color'>
   1079 	/// 	- The color of the circle.
   1080 	/// </param>
   1081 	/// <param name='radius'>
   1082 	/// 	- The radius of the circle.
   1083 	/// </param>
   1084 	public static void DrawCircle(Vector3 position, Color color, float radius = 1.0f)
   1085 	{
   1086 		DrawCircle(position, Vector3.up, color, radius);
   1087 	}
   1088 	
   1089 	/// <summary>
   1090 	/// 	- Draws a circle.
   1091 	/// </summary>
   1092 	/// <param name='position'>
   1093 	/// 	- Where the center of the circle will be positioned.
   1094 	/// </param>
   1095 	/// <param name='up'>
   1096 	/// 	- The direction perpendicular to the surface of the circle.
   1097 	/// </param>
   1098 	/// <param name='radius'>
   1099 	/// 	- The radius of the circle.
   1100 	/// </param>
   1101 	public static void DrawCircle(Vector3 position, Vector3 up, float radius = 1.0f)
   1102 	{
   1103 		DrawCircle(position, position, Color.white, radius);
   1104 	}
   1105 	
   1106 	/// <summary>
   1107 	/// 	- Draws a circle.
   1108 	/// </summary>
   1109 	/// <param name='position'>
   1110 	/// 	- Where the center of the circle will be positioned.
   1111 	/// </param>
   1112 	/// <param name='radius'>
   1113 	/// 	- The radius of the circle.
   1114 	/// </param>
   1115 	public static void DrawCircle(Vector3 position, float radius = 1.0f)
   1116 	{
   1117 		DrawCircle(position, Vector3.up, Color.white, radius);
   1118 	}
   1119 	
   1120 	//Wiresphere already exists
   1121 	
   1122 	/// <summary>
   1123 	/// 	- Draws a cylinder.
   1124 	/// </summary>
   1125 	/// <param name='start'>
   1126 	/// 	- The position of one end of the cylinder.
   1127 	/// </param>
   1128 	/// <param name='end'>
   1129 	/// 	- The position of the other end of the cylinder.
   1130 	/// </param>
   1131 	/// <param name='color'>
   1132 	/// 	- The color of the cylinder.
   1133 	/// </param>
   1134 	/// <param name='radius'>
   1135 	/// 	- The radius of the cylinder.
   1136 	/// </param>
   1137 	public static void DrawCylinder(Vector3 start, Vector3 end, Color color, float radius = 1.0f){
   1138 		Vector3 up = (end-start).normalized*radius;
   1139 		Vector3 forward = Vector3.Slerp(up, -up, 0.5f);
   1140 		Vector3 right = Vector3.Cross(up, forward).normalized*radius;
   1141 		
   1142 		//Radial circles
   1143 		DebugExtension.DrawCircle(start, up, color, radius);	
   1144 		DebugExtension.DrawCircle(end, -up, color, radius);
   1145 		DebugExtension.DrawCircle((start+end)*0.5f, up, color, radius);
   1146 		
   1147 		Color oldColor = Gizmos.color;
   1148 		Gizmos.color = color;
   1149 		
   1150 		//Side lines
   1151 		Gizmos.DrawLine(start+right, end+right);
   1152 		Gizmos.DrawLine(start-right, end-right);
   1153 		
   1154 		Gizmos.DrawLine(start+forward, end+forward);
   1155 		Gizmos.DrawLine(start-forward, end-forward);
   1156 		
   1157 		//Start endcap
   1158 		Gizmos.DrawLine(start-right, start+right);
   1159 		Gizmos.DrawLine(start-forward, start+forward);
   1160 		
   1161 		//End endcap
   1162 		Gizmos.DrawLine(end-right, end+right);
   1163 		Gizmos.DrawLine(end-forward, end+forward);
   1164 		
   1165 		Gizmos.color = oldColor;
   1166 	}
   1167 	
   1168 	/// <summary>
   1169 	/// 	- Draws a cylinder.
   1170 	/// </summary>
   1171 	/// <param name='start'>
   1172 	/// 	- The position of one end of the cylinder.
   1173 	/// </param>
   1174 	/// <param name='end'>
   1175 	/// 	- The position of the other end of the cylinder.
   1176 	/// </param>
   1177 	/// <param name='radius'>
   1178 	/// 	- The radius of the cylinder.
   1179 	/// </param>
   1180 	public static void DrawCylinder(Vector3 start, Vector3 end, float radius = 1.0f)
   1181 	{
   1182 		DrawCylinder(start, end, Color.white, radius);
   1183 	}
   1184 	
   1185 	/// <summary>
   1186 	/// 	- Draws a cone.
   1187 	/// </summary>
   1188 	/// <param name='position'>
   1189 	/// 	- The position for the tip of the cone.
   1190 	/// </param>
   1191 	/// <param name='direction'>
   1192 	/// 	- The direction for the cone to get wider in.
   1193 	/// </param>
   1194 	/// <param name='color'>
   1195 	/// 	- The color of the cone.
   1196 	/// </param>
   1197 	/// <param name='angle'>
   1198 	/// 	- The angle of the cone.
   1199 	/// </param>
   1200 	public static void DrawCone(Vector3 position, Vector3 direction, Color color, float angle = 45)
   1201 	{
   1202 		float length = direction.magnitude;
   1203 		
   1204 		Vector3 _forward = direction;
   1205 		Vector3 _up = Vector3.Slerp(_forward, -_forward, 0.5f);
   1206 		Vector3 _right = Vector3.Cross(_forward, _up).normalized*length;
   1207 		
   1208 		direction = direction.normalized;
   1209 		
   1210 		Vector3 slerpedVector = Vector3.Slerp(_forward, _up, angle/90.0f);
   1211 		
   1212 		float dist;
   1213 		var farPlane = new Plane(-direction, position+_forward);
   1214 		var distRay = new Ray(position, slerpedVector);
   1215 	
   1216 		farPlane.Raycast(distRay, out dist); 
   1217 		
   1218 		Color oldColor = Gizmos.color;
   1219 		Gizmos.color = color;
   1220 		
   1221 		Gizmos.DrawRay(position, slerpedVector.normalized*dist);
   1222 		Gizmos.DrawRay(position, Vector3.Slerp(_forward, -_up, angle/90.0f).normalized*dist);
   1223 		Gizmos.DrawRay(position, Vector3.Slerp(_forward, _right, angle/90.0f).normalized*dist);
   1224 		Gizmos.DrawRay(position, Vector3.Slerp(_forward, -_right, angle/90.0f).normalized*dist);
   1225 		
   1226 		DebugExtension.DrawCircle(position+_forward, direction, color, (_forward-(slerpedVector.normalized*dist)).magnitude);
   1227 		DebugExtension.DrawCircle(position+(_forward*0.5f), direction, color, ((_forward*0.5f)-(slerpedVector.normalized*(dist*0.5f))).magnitude);
   1228 		
   1229 		Gizmos.color = oldColor;
   1230 	}
   1231 	
   1232 	/// <summary>
   1233 	/// 	- Draws a cone.
   1234 	/// </summary>
   1235 	/// <param name='position'>
   1236 	/// 	- The position for the tip of the cone.
   1237 	/// </param>
   1238 	/// <param name='direction'>
   1239 	/// 	- The direction for the cone to get wider in.
   1240 	/// </param>
   1241 	/// <param name='angle'>
   1242 	/// 	- The angle of the cone.
   1243 	/// </param>
   1244 	public static void DrawCone(Vector3 position, Vector3 direction, float angle = 45)
   1245 	{
   1246 		DrawCone(position, direction, Color.white, angle);
   1247 	}
   1248 	
   1249 	/// <summary>
   1250 	/// 	- Draws a cone.
   1251 	/// </summary>
   1252 	/// <param name='position'>
   1253 	/// 	- The position for the tip of the cone.
   1254 	/// </param>
   1255 	/// <param name='color'>
   1256 	/// 	- The color of the cone.
   1257 	/// </param>
   1258 	/// <param name='angle'>
   1259 	/// 	- The angle of the cone.
   1260 	/// </param>
   1261 	public static void DrawCone(Vector3 position, Color color, float angle = 45)
   1262 	{
   1263 		DrawCone(position, Vector3.up, color, angle);
   1264 	}
   1265 	
   1266 	/// <summary>
   1267 	/// 	- Draws a cone.
   1268 	/// </summary>
   1269 	/// <param name='position'>
   1270 	/// 	- The position for the tip of the cone.
   1271 	/// </param>
   1272 	/// <param name='angle'>
   1273 	/// 	- The angle of the cone.
   1274 	/// </param>
   1275 	public static void DrawCone(Vector3 position, float angle = 45)
   1276 	{
   1277 		DrawCone(position, Vector3.up, Color.white, angle);
   1278 	}
   1279 	
   1280 	/// <summary>
   1281 	/// 	- Draws an arrow.
   1282 	/// </summary>
   1283 	/// <param name='position'>
   1284 	/// 	- The start position of the arrow.
   1285 	/// </param>
   1286 	/// <param name='direction'>
   1287 	/// 	- The direction the arrow will point in.
   1288 	/// </param>
   1289 	/// <param name='color'>
   1290 	/// 	- The color of the arrow.
   1291 	/// </param>
   1292 	public static void DrawArrow(Vector3 position, Vector3 direction, Color color)
   1293 	{	
   1294 		Color oldColor = Gizmos.color;
   1295 		Gizmos.color = color;
   1296 		
   1297 		Gizmos.DrawRay(position, direction);
   1298 		DebugExtension.DrawCone(position+direction, -direction*0.333f, color, 15);
   1299 		
   1300 		Gizmos.color = oldColor;
   1301 	}
   1302 	
   1303 	/// <summary>
   1304 	/// 	- Draws an arrow.
   1305 	/// </summary>
   1306 	/// <param name='position'>
   1307 	/// 	- The start position of the arrow.
   1308 	/// </param>
   1309 	/// <param name='direction'>
   1310 	/// 	- The direction the arrow will point in.
   1311 	/// </param>
   1312 	public static void DrawArrow(Vector3 position, Vector3 direction)
   1313 	{
   1314 		DrawArrow(position, direction, Color.white);
   1315 	}
   1316 	
   1317 	/// <summary>
   1318 	/// 	- Draws a capsule.
   1319 	/// </summary>
   1320 	/// <param name='start'>
   1321 	/// 	- The position of one end of the capsule.
   1322 	/// </param>
   1323 	/// <param name='end'>
   1324 	/// 	- The position of the other end of the capsule.
   1325 	/// </param>
   1326 	/// <param name='color'>
   1327 	/// 	- The color of the capsule.
   1328 	/// </param>
   1329 	/// <param name='radius'>
   1330 	/// 	- The radius of the capsule.
   1331 	/// </param>
   1332 	public static void DrawCapsule(Vector3 start, Vector3 end, Color color, float radius = 1)
   1333 	{
   1334 		Vector3 up = (end-start).normalized*radius;
   1335 		Vector3 forward = Vector3.Slerp(up, -up, 0.5f);
   1336 		Vector3 right = Vector3.Cross(up, forward).normalized*radius;
   1337 		
   1338 		Color oldColor = Gizmos.color;
   1339 		Gizmos.color = color;
   1340 		
   1341 		float height = (start-end).magnitude;
   1342 		float sideLength = Mathf.Max(0, (height*0.5f)-radius);
   1343 		Vector3 middle = (end+start)*0.5f;
   1344 		
   1345 		start = middle+((start-middle).normalized*sideLength);
   1346 		end = middle+((end-middle).normalized*sideLength);
   1347 		
   1348 		//Radial circles
   1349 		DebugExtension.DrawCircle(start, up, color, radius);	
   1350 		DebugExtension.DrawCircle(end, -up, color, radius);
   1351 		
   1352 		//Side lines
   1353 		Gizmos.DrawLine(start+right, end+right);
   1354 		Gizmos.DrawLine(start-right, end-right);
   1355 		
   1356 		Gizmos.DrawLine(start+forward, end+forward);
   1357 		Gizmos.DrawLine(start-forward, end-forward);
   1358 		
   1359 		for(int i = 1; i < 26; i++){
   1360 			
   1361 			//Start endcap
   1362 			Gizmos.DrawLine(Vector3.Slerp(right, -up, i/25.0f)+start, Vector3.Slerp(right, -up, (i-1)/25.0f)+start);
   1363 			Gizmos.DrawLine(Vector3.Slerp(-right, -up, i/25.0f)+start, Vector3.Slerp(-right, -up, (i-1)/25.0f)+start);
   1364 			Gizmos.DrawLine(Vector3.Slerp(forward, -up, i/25.0f)+start, Vector3.Slerp(forward, -up, (i-1)/25.0f)+start);
   1365 			Gizmos.DrawLine(Vector3.Slerp(-forward, -up, i/25.0f)+start, Vector3.Slerp(-forward, -up, (i-1)/25.0f)+start);
   1366 			
   1367 			//End endcap
   1368 			Gizmos.DrawLine(Vector3.Slerp(right, up, i/25.0f)+end, Vector3.Slerp(right, up, (i-1)/25.0f)+end);
   1369 			Gizmos.DrawLine(Vector3.Slerp(-right, up, i/25.0f)+end, Vector3.Slerp(-right, up, (i-1)/25.0f)+end);
   1370 			Gizmos.DrawLine(Vector3.Slerp(forward, up, i/25.0f)+end, Vector3.Slerp(forward, up, (i-1)/25.0f)+end);
   1371 			Gizmos.DrawLine(Vector3.Slerp(-forward, up, i/25.0f)+end, Vector3.Slerp(-forward, up, (i-1)/25.0f)+end);
   1372 		}
   1373 		
   1374 		Gizmos.color = oldColor;
   1375 	}
   1376 	
   1377 	/// <summary>
   1378 	/// 	- Draws a capsule.
   1379 	/// </summary>
   1380 	/// <param name='start'>
   1381 	/// 	- The position of one end of the capsule.
   1382 	/// </param>
   1383 	/// <param name='end'>
   1384 	/// 	- The position of the other end of the capsule.
   1385 	/// </param>
   1386 	/// <param name='radius'>
   1387 	/// 	- The radius of the capsule.
   1388 	/// </param>
   1389 	public static void DrawCapsule(Vector3 start, Vector3 end, float radius = 1)
   1390 	{
   1391 		DrawCapsule(start, end, Color.white, radius);
   1392 	}
   1393 	
   1394 	#endregion
   1395 	
   1396 	#region DebugFunctions
   1397 	
   1398 	/// <summary>
   1399 	/// 	- Gets the methods of an object.
   1400 	/// </summary>
   1401 	/// <returns>
   1402 	/// 	- A list of methods accessible from this object.
   1403 	/// </returns>
   1404 	/// <param name='obj'>
   1405 	/// 	- The object to get the methods of.
   1406 	/// </param>
   1407 	/// <param name='includeInfo'>
   1408 	/// 	- Whether or not to include each method's method info in the list.
   1409 	/// </param>
   1410 	public static string MethodsOfObject(System.Object obj, bool includeInfo = false){
   1411 		string methods = "";
   1412 		MethodInfo[] methodInfos = obj.GetType().GetMethods();
   1413 		for(int i = 0; i < methodInfos.Length; i++){
   1414 			if(includeInfo){
   1415 				methods += methodInfos[i]+"\n";
   1416 			}
   1417 			
   1418 			else{
   1419 				methods += methodInfos[i].Name+"\n";
   1420 			}
   1421 		}
   1422 		
   1423 		return (methods);
   1424 	}
   1425 	
   1426 	/// <summary>
   1427 	/// 	- Gets the methods of a type.
   1428 	/// </summary>
   1429 	/// <returns>
   1430 	/// 	- A list of methods accessible from this type.
   1431 	/// </returns>
   1432 	/// <param name='type'>
   1433 	/// 	- The type to get the methods of.
   1434 	/// </param>
   1435 	/// <param name='includeInfo'>
   1436 	/// 	- Whether or not to include each method's method info in the list.
   1437 	/// </param>
   1438 	public static string MethodsOfType(System.Type type, bool includeInfo = false){
   1439 		string methods = "";
   1440 		MethodInfo[] methodInfos = type.GetMethods();
   1441 		for(var i = 0; i < methodInfos.Length; i++){
   1442 			if(includeInfo){
   1443 				methods += methodInfos[i]+"\n";
   1444 			}
   1445 			
   1446 			else{
   1447 				methods += methodInfos[i].Name+"\n";
   1448 			}
   1449 		}
   1450 		
   1451 		return (methods);
   1452 	}
   1453 	
   1454 	#endregion
   1455 }