Debug.Log Extensions
Documentation (1.1.9)

◆ DrawLine() [2/2]

static void Debug.DrawLine ( Vector3  start,
Vector3  end,
Color  color,
float  duration = 0f,
bool  depthTest = true 

Draws a line between specified start and end points.

The line will be drawn in the Game view of the editor when the game is running and the gizmo drawing is enabled. The line will also be drawn in the Scene when it is visible in the Game view. Leave the game running and showing the line. Switch to the Scene view and the line will be visible.

The duration is the time (in seconds) for which the line will be visible after it is first displayed. A duration of zero shows the line for just one frame.

Note: This is for debugging playmode only. Editor gizmos should be drawn with Gizmos.DrawLine or Handles.DrawLine instead.

using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
public Transform target;
void OnDrawGizmosSelected()
if (target != null)
// Draws a blue line from this transform to the target
Gizmos.color =;
Gizmos.DrawLine(transform.position, target.position,;
startPoint in world space where the line should start.
endPoint in world space where the line should end.
colorColor of the line.
durationHow long the line should be visible for.
depthTestShould the line be obscured by objects closer to the camera?