Really Simple: Debug.DrawLine just will not show up

This should be really easy to solve. I must be high on something, because I cannot figure it out.

    function Update () {
    	Debug.DrawLine(Vector3(200,200,200), Vector3.zero);
    	print("You should see a line");
    }

This code will print the text, but it will not draw any lines. Why not? I’ve got to be missing something simple.

1 Like

when u click on the play button to play the scene,u have to enable gizmos,which are on the top right corner.then u will see the lines.case closed.

it is because it will draw a line for a single frame. if you want to see a line for longer use this. Debug.DrawLine(Vector3(200,200,200), Vector3.zero, Color.green, 2, false);

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

@CHPedersen Have Gizmos button enabled but still line won’t show up even in scene view.

I know this is old (comes up in google), but I got away with a cube scaled to (0.01, 0.01, 10) for my purposes. I made it 50% transparent and turned off shadows (cast and received, in its mesh renderer).

Another late answer but for anyone else who found that none of the solutions above worked, in my case my issue was that I have a 2D project and the Z value of my DrawLine positions were behind the camera. Manually setting those to be a value in front of the camera resolved my problem (along with enabling gizmos and setting a large duration as mentioned above).

Because time is independent of frame rate you have to tell it to draw the line for the time between frames:

Debug.DrawLine(Vector3(200,200,200), Vector3.zero, Color.green, Time.deltaTime, false);

If you use something other than “Time.deltaTime” then you either won’t see the line or it will create tracers (multiple lines) and you can only see the lines in the editor view so make sure you take your game out of full screen when testing it.