Unable to draw single pixel width lines in screen space

Hi all,

So far I’ve only been able to get the package to draw double-pixel width lines in play mode using the example below. Am I doing something incorrectly or is there currently a limitation on line width?

public class ALineTest : MonoBehaviour
    {
        public Color gizmoColor = new Color(1.0f, 88/255f, 85/255f);

        private void Update()
        {
            using (var draw = DrawingManager.GetBuilder(true))
            {
                using (draw.InScreenSpace(Camera.main))
                {
                    using (draw.WithLineWidth(1.0f))
                    {
                        draw.Line(new Vector3(1000, 0, 0), new Vector3(1000, 1000, 0), gizmoColor);
                        draw.Line(new Vector3(0, 100, 0), new Vector3(1000, 100, 0), gizmoColor);
                    }
                }
            }
        }
    }

I’m running Unity 2022.2.19 on Windows 11 (AMD Ryzen 9 5950X/NVIDIA GeForce RTX 3060). Any help would be appreciated.

Hi

I think, due to how the math works out, those lines will end up right on the border between two pixels. Try adding 0.5 to the X and Y coordinates and I think it will work well. I just tried this locally and the lines are now 1px wide. This might be something I should do automatically in the InScreenSpace scope. I will consider this for the future.

Confirmed. Everything is working nicely now. Thanks!

1 Like