using System.ComponentModel;
using UnityEngine;
namespace DebugDrawEx
{
public static class DebugDraw
{
///
/// Draws a line between specified start and end points.
///
/// Point in world space where the line should start.
/// Point in world space where the line should end.
/// Color of the line.
/// How long the line should be visible for.
/// Should the line be obscured by objects closer to the camera?
public static void DrawLine(Vector3 start, Vector3 end)
{
bool depthTest = true;
float duration = 0.0f;
Color white = Color.white;
DrawLine(start, end, white, duration, depthTest);
}
///
/// Draws a line between specified start and end points.
///
/// Point in world space where the line should start.
/// Point in world space where the line should end.
/// Color of the line.
/// How long the line should be visible for.
/// Should the line be obscured by objects closer to the camera?
public static void DrawLine(Vector3 start, Vector3 end, Color color)
{
bool depthTest = true;
float duration = 0.0f;
DrawLine(start, end, color, duration, depthTest);
}
///
/// Draws a line between specified start and end points.
///
/// Point in world space where the line should start.
/// Point in world space where the line should end.
/// Color of the line.
/// How long the line should be visible for.
/// Should the line be obscured by objects closer to the camera?
public static void DrawLine(Vector3 start, Vector3 end, Color color, float duration)
{
bool depthTest = true;
DrawLine(start, end, color, duration, depthTest);
}
///
/// Draws a line between specified start and end points.
///
/// Point in world space where the line should start.
/// Point in world space where the line should end.
/// Color of the line.
/// How long the line should be visible for.
/// Should the line be obscured by objects closer to the camera?
public static void DrawLine(
Vector3 start,
Vector3 end,
[DefaultValue("Color.white")] Color color,
[DefaultValue("0.0f")] float duration,
[DefaultValue("true")] bool depthTest)
{
var line = new Line
{
Duration = duration,
DepthTest = depthTest
};
line.AddLine(start, end, color);
Graphics.DrawMesh(line.Mesh, Vector3.zero, Quaternion.identity, line.Mat,
0 , null, 0, null, false,false);
}
///
/// Draws a line from start to start + dir in world coordinates.
///
/// Point in world space where the ray should start.
/// Direction and length of the ray.
/// Color of the drawn line.
/// How long the line will be visible for (in seconds).
/// Should the line be obscured by other objects closer to the camera?
public static void DrawRay(Vector3 start, Vector3 dir)
{
bool depthTest = true;
float duration = 0.0f;
Color white = Color.white;
DrawRay(start, dir, white, duration, depthTest);
}
///
/// Draws a line from start to start + dir in world coordinates.
///
/// Point in world space where the ray should start.
/// Direction and length of the ray.
/// Color of the drawn line.
/// How long the line will be visible for (in seconds).
/// Should the line be obscured by other objects closer to the camera?
public static void DrawRay(Vector3 start, Vector3 dir, Color color)
{
bool depthTest = true;
float duration = 0.0f;
DrawRay(start, dir, color, duration, depthTest);
}
///
/// Draws a line from start to start + dir in world coordinates.
///
/// Point in world space where the ray should start.
/// Direction and length of the ray.
/// Color of the drawn line.
/// How long the line will be visible for (in seconds).
/// Should the line be obscured by other objects closer to the camera?
public static void DrawRay(Vector3 start, Vector3 dir, Color color, float duration)
{
bool depthTest = true;
DrawRay(start, dir, color, duration, depthTest);
}
///
/// Draws a line from start to start + dir in world coordinates.
///
/// Point in world space where the ray should start.
/// Direction and length of the ray.
/// Color of the drawn line.
/// How long the line will be visible for (in seconds).
/// Should the line be obscured by other objects closer to the camera?
public static void DrawRay(
Vector3 start,
Vector3 dir,
[DefaultValue("Color.white")] Color color,
[DefaultValue("0.0f")] float duration,
[DefaultValue("true")] bool depthTest)
{
DrawLine(start, start + dir, color, duration, depthTest);
}
}
}