Debug.DrawLine

static function DrawLine (start : Vector3, end : Vector3, color : Color = Color.white, duration : float = 0.0f, depthTest : boolean = true) : void

Description

Draws a line from the point start to end with color for a duration of time and with or without depth testing. If duration is 0 then the line is rendered 1 frame.

The line will be drawn in the scene view of the editor. If gizmo drawing is enabled in the game view, the line will also be drawn there. Note: This is for debugging playmode only. Editor gizmos should be drawn with Gizmos.Drawline or Handles.DrawLine instead.

JavaScript
// Frame update example: Draws a red line from the world-space origin to the point (1, 0, 0) for 1 frame.
function Update () {
Debug.DrawLine (Vector3.zero, Vector3 (1, 0, 0), Color.red);
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Update() {
Debug.DrawLine(Vector3.zero, new Vector3(1, 0, 0), Color.red);
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Update():
Debug.DrawLine(Vector3.zero, Vector3(1, 0, 0), Color.red)

JavaScript

// Event callback example: Debug-draw all contact points and normals for 2 seconds.
function OnCollisionEnter(collision : Collision) {
for (var contact : ContactPoint in collision.contacts) {
Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2, false);
}
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void OnCollisionEnter(Collision collision) {
foreach (ContactPoint contact in collision.contacts) {
Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2, false);
}
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def OnCollisionEnter(collision as Collision):
for contact as ContactPoint in collision.contacts:
Debug.DrawLine(contact.point, (contact.point + contact.normal), Color.green, 2, false)