I have a custom editor to which I want to be able to draw a basic line graph. I have much of the functionality down, but I have only been able to test as much via the debug. I am yet to figure out how to draw the actual lines to the inspector.
How do I draw lines to a custom inspector?
I have found plenty of online resources, in regards to custom drawing to the editor. However, everything I find pertains specifically to drawing in the scene view; nothing seems to work inside of an actual inspector.
The two general methods I have found involve using Handles.DrawLine and the GL library. Neither appear to work; however, I have only been able to test functionality with blind coordinates, so far. I can not find anything in regards to actually determining the local coordinates of the area on the inspector where I wish to draw. Perhaps I need to start with an initial "origin" position, Perhaps I need to start with a local area defined by a Rect. I simply don't know.
It has also been a while since I had to use OpenGL, directly. It is entirely possible I am simply doing it wrong, to begin with. Here is my current graph method:
private void DrawVelocityGraph(float[] velocityValues, float minimumVelocity,
float maximumVelocity)
{
float velocityValue = velocityValues[0];
float increment = 0;
Vector3 lineStart = Vector3.zero;
Vector3 lineEnd = new Vector3(horizontalIncrement, velocityValue * verticalIncrement);
GL.Begin(GL.LINES);
for(int i = 1; i < velocityValues.Length; i++)
{
if(velocityValue == velocityValues[i]
&& (velocityValue == minimumVelocity || velocityValue == maximumVelocity))
{
Handles.color = VelocityGrapherColours.outOfRangeColour;
}
else
{
velocityValue = velocityValues[i];
Handles.color = VelocityGrapherColours.lineColour;
}
lineStart = lineEnd;
lineEnd.x += increment;
lineEnd.y = velocityValue * verticalIncrement;
GL.Vertex(lineStart);
GL.Vertex(lineEnd);
}
GL.End();
}


CurveFieldmanages curved lines; they would not be suitable for the task I have described. \$\endgroup\$