- Home /
LineRender width not consistent across resolutions
I have a LineRenderer as a child of a canvas. If I remove "Use World Space," on the LineRenderer, the endpoints correctly stay anchored to the canvas as I switch to various resolutions (they stay at the same relative positions). The width however, does not locally stay consistent.
For instance if the width is set to 0.12 at 1920x1080, it needs to be set to 0.09 at 1134x750 in order to match the space it takes up on the canvas. For 2048x1536 it needs to be set to 0.06.
What is the proper way to make line render widths remain consistent to the canvas across different resolutions?
This sounds wrong. Scaling down even though the resolutions mentioned are larger AND smaller than the reference resolution? This is from the docs and should help you figuring out how to calculate the right width:
The Line Renderer does not render one-pixel-wide lines. It renders billboard lines (polygons that always face the camera) that have a width in world units and can be textured
Try it for yourself! Create a Canvas, Create a game object with a line renderer, turn off "Use World Space" on the LineRenderer and see that if you switch between resolutions, you get various widths that don't really correspond to resolution sizes in a meaningful way (or at least that I can tell!).
It's strange that something as basic as line renderers have highly variable line widths at various resolutions. Anyone know how this is calculated?
Why use line renderer inside canvas? Line renderer is more for 3d space and it's not a sprite that can adapt his properties acccording to canvas.
Why? Because a line renderer can otherwise achieve what is needed (being able to draw a line with many points, smooth corners, interpolate colors down a gradient, etc). Why recreate all of this functionality when everything else, except for the width, is working properly?
I'm hoping someone can shed light on how the width is calculated or how to make a resolution independent solution for drawing lines.
introduce width coefficient, calculate it at the start of application in base of resolution, and multiply every line width by it.
Answer by ChrisBellU · Sep 12, 2018 at 11:01 AM
Hit this problem just now (2018.2.5). The width isn't scaled with the LineRenderer even if the line is locally scaled.