Snippet: Drawing Lines In Editor WindowsDecember 19, 2014
This script was written by Yossarian King and Linusmartensson.
This script makes it easy to draw lines in editor windows, which is perfect for creating separator lines or showing connections between nodes. Here’s an example of that from our dialogue editor:
Line drawing in editor window
To use this script, simply call the following function in the OnGUI function of an editor window.
Where pointA is the starting point of the line, and pointB is the end of the line. This will draw a straight line between those points. To draw a curved line like in the image at the top of this post you can either use the DrawBezierLine function of the above script, or use a function that’s built into Unity (which is what I use in the above picture). The code below is what I use to draw those lines.
I haven’t done a performance test of the DrawBezierLine against the Unity DrawBezier, but if it works it works (and generally I don’t try to overthink performance when writing editor scripts).