Invert DrawLine direction in editor Window.

I’m trying to make a bar graph in an editor window, the problem is, when I increase the value the line goes down and not up. How do I invert this? I tried the Y value in both vector 3s, and tried to use a negative value.



Code:

                    int v = 50;
                    foreach(int i in maxHp)
                    {
                        GUI.BeginClip(new Rect (v, 91, 5, 430));
                        Handles.color = Color.red;
                        Handles.DrawLine(new Vector3(0, i/23, 0), new Vector3(0, 0, 0), 6f);
                        GUI.EndClip();
                        v = v + 6;
                    }

1 Answer

1

I assume 0,0 is in the top left corner. So you just need to draw the line from the Rects height to the Rects height minus the length of the line.

Ah, good shout. I'll give that try.

Cracked it. Thank you so much. ![alt text][1] int v = 50; foreach(int i in maxHp) { GUI.BeginClip(new Rect (v, 91, 5, 430)); Handles.color = new Color(0.95f, 0.1f, 0.45f); Handles.DrawLine(new Vector3(0, 430, 0), new Vector3(0, 430-i/23, 0), 6f); GUI.EndClip(); v = v + 6; } [1]: /storage/temp/189311-parameterwindowfixed.png