How to draw lines in the Editor?

I’ve been trying to use the Handle class to draw lines in the editor with no success. I’ve placed the following script in the Assets/Editor folder

using UnityEditor;
using UnityEngine;
using System.Collections;

[ExecuteInEditMode]
public class LineDrawer : MonoBehaviour {

	public void OnSceneGUI()
	{
		Handles.BeginGUI();
		Handles.color = Color.red;
		Handles.DrawLine( Vector3.zero, Vector3.one * 10);
		Handles.EndGUI();
	}
}

I’ve also tried using OnGUI instead of OnSceneGUI. But no line ever shows up in my scene.

I don’t think OnSceneGUI is called on Monobehaviours. You need to create a custom Editor for your class and move the OnSceneGUI method there.

Otherwise you can use OnDrawGizmos and Gizmos.DrawLine in your current class.

I’ve never used the handles class, but this works for me.

void Update()
{
    Debug.DrawLine(Vector3.zero, Vector3.up, Color.red);
}