- Home /
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;
}
Answer by sacredgeometry · Nov 28, 2021 at 09:47 PM
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.
Cracked it. Thank you so much.
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;
}
Your answer
Follow this Question
Related Questions
Reset or Reinstantiate Custom Editors Target(s) 1 Answer
Scene view controls locking up > trying to make scene view generic menu on right click 0 Answers
Edit an object in isolation quickly, as in the new Prefab Mode 0 Answers
Editor window script only works when window is open? 1 Answer
In search of a gradient editor tool.. 0 Answers