- Home /
Gizmo.DrawLine rendering problem
Hi, I made a simple gizmo for my 2D shooter game in order to display the boundaries for my spaceship's movement (in green), and a visualisation of its movement speed (in red)
But the gizmo is inconsistently rendered in the editor, some lines appear super thin, almost invisible while some appear just nice, and if I zoom out, it's other lines that become invisible.
I have the problem in both the scene view and the game view.
Any idea of a way I could solve this? Only workaround I found was to add a for loop to draw each line several times and offset them by 0.01f
edit: here's my code.
void DrawBoundsGizmo(Rect zone) {
Gizmos.color = Color.green;
Gizmos.DrawLine (new Vector3 (zone.xMin, zone.yMin), new Vector3 (zone.xMin, zone.yMax));
Gizmos.DrawLine (new Vector3 (zone.xMin, zone.yMax), new Vector3 (zone.xMax, zone.yMax));
Gizmos.DrawLine (new Vector3 (zone.xMax, zone.yMax), new Vector3 (zone.xMax, zone.yMin));
Gizmos.DrawLine (new Vector3 (zone.xMax, zone.yMin), new Vector3 (zone.xMin, zone.yMin));
}
10 days without any answer :-( please I'm sure I can't be the only one with this problem
Answer by Bunny83 · Jul 30, 2016 at 02:01 AM
Well, i never had such problems. I could imagine that you might draw the lines in between pixels. Have you checked what values your rect has? Do you run your monitor that the monitor's native resolution? If not such things could happen. What OS are you using?
I'm on $$anonymous$$ac OSX, running on native resolution (2560 * 1440) on a 27 inch Thunderbolt2 display. $$anonymous$$y rect has values X=0 Y=-7 H=14 W = 26 nothing out of the ordinary I would say.
Note that I'm in 2D orthographic view. The lines are much more visible with a perspective camera.
Guess this might be a bug with the renderer...
If it's an orthographic camera are you sure it isn't located at an odd position? $$anonymous$$eep in $$anonymous$$d if you've 0.5 off you're between two pixels. It also depends on the orthographic size of the camera.
Your answer
