|
|
using System.ComponentModel; using UnityEngine;
namespace DebugDrawEx { public static class DebugDraw { /// <summary>
/// <para>Draws a line between specified start and end points.</para>
/// </summary>
/// <param name="start">Point in world space where the line should start.</param>
/// <param name="end">Point in world space where the line should end.</param>
/// <param name="color">Color of the line.</param>
/// <param name="duration">How long the line should be visible for.</param>
/// <param name="depthTest">Should the line be obscured by objects closer to the camera?</param>
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); } /// <summary>
/// <para>Draws a line between specified start and end points.</para>
/// </summary>
/// <param name="start">Point in world space where the line should start.</param>
/// <param name="end">Point in world space where the line should end.</param>
/// <param name="color">Color of the line.</param>
/// <param name="duration">How long the line should be visible for.</param>
/// <param name="depthTest">Should the line be obscured by objects closer to the camera?</param>
public static void DrawLine(Vector3 start, Vector3 end, Color color) { bool depthTest = true; float duration = 0.0f; DrawLine(start, end, color, duration, depthTest); } /// <summary>
/// <para>Draws a line between specified start and end points.</para>
/// </summary>
/// <param name="start">Point in world space where the line should start.</param>
/// <param name="end">Point in world space where the line should end.</param>
/// <param name="color">Color of the line.</param>
/// <param name="duration">How long the line should be visible for.</param>
/// <param name="depthTest">Should the line be obscured by objects closer to the camera?</param>
public static void DrawLine(Vector3 start, Vector3 end, Color color, float duration) { bool depthTest = true; DrawLine(start, end, color, duration, depthTest); } /// <summary>
/// <para>Draws a line between specified start and end points.</para>
/// </summary>
/// <param name="start">Point in world space where the line should start.</param>
/// <param name="end">Point in world space where the line should end.</param>
/// <param name="color">Color of the line.</param>
/// <param name="duration">How long the line should be visible for.</param>
/// <param name="depthTest">Should the line be obscured by objects closer to the camera?</param>
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); } /// <summary>
/// <para>Draws a line from start to start + dir in world coordinates.</para>
/// </summary>
/// <param name="start">Point in world space where the ray should start.</param>
/// <param name="dir">Direction and length of the ray.</param>
/// <param name="color">Color of the drawn line.</param>
/// <param name="duration">How long the line will be visible for (in seconds).</param>
/// <param name="depthTest">Should the line be obscured by other objects closer to the camera?</param>
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); } /// <summary>
/// <para>Draws a line from start to start + dir in world coordinates.</para>
/// </summary>
/// <param name="start">Point in world space where the ray should start.</param>
/// <param name="dir">Direction and length of the ray.</param>
/// <param name="color">Color of the drawn line.</param>
/// <param name="duration">How long the line will be visible for (in seconds).</param>
/// <param name="depthTest">Should the line be obscured by other objects closer to the camera?</param>
public static void DrawRay(Vector3 start, Vector3 dir, Color color) { bool depthTest = true; float duration = 0.0f; DrawRay(start, dir, color, duration, depthTest); } /// <summary>
/// <para>Draws a line from start to start + dir in world coordinates.</para>
/// </summary>
/// <param name="start">Point in world space where the ray should start.</param>
/// <param name="dir">Direction and length of the ray.</param>
/// <param name="color">Color of the drawn line.</param>
/// <param name="duration">How long the line will be visible for (in seconds).</param>
/// <param name="depthTest">Should the line be obscured by other objects closer to the camera?</param>
public static void DrawRay(Vector3 start, Vector3 dir, Color color, float duration) { bool depthTest = true; DrawRay(start, dir, color, duration, depthTest); }
/// <summary>
/// <para>Draws a line from start to start + dir in world coordinates.</para>
/// </summary>
/// <param name="start">Point in world space where the ray should start.</param>
/// <param name="dir">Direction and length of the ray.</param>
/// <param name="color">Color of the drawn line.</param>
/// <param name="duration">How long the line will be visible for (in seconds).</param>
/// <param name="depthTest">Should the line be obscured by other objects closer to the camera?</param>
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); } } }
|