i’d love to know if there was a way to get my lineRenderer on a canvas (or some other way to draw lines on a canvas)
If anyone’s still looking for the answer:
Use “Screen Space - Camera”, assign the camera, and increase the width of the line so it becomes visible.
Hi just use a panel filled with any color you want and use Height and Widith to set the length and the widith of your line,
Just tried this and it simply doesn’t render on the UI. I can see the line on the canvas exactly where I expect in the scene view but it’s not there on the Game view.
However whilst looking at why it wasn’t rendering I came across this page …
Maybe that’ll help.
I ran across two other solutions not mentioned here while looking for a way to draw lines in a UI canvas. These solutions probably don’t apply to all situations, but they may be helpful to some.
Render Texture Solution
- Create a Render Texture in your assets.
- Create a second camera in your scene.
- In your second camera’s Target Texture option, specify your new Render Texture.
- Assemble your Line Renderer and some background Quad some distance away from your GameObjects. Make your second camera watch that.
- Create a Raw Image in your Canvas and have it render your Render Texture.
Low Level Graphics Solution
- Use Unity’s low level graphics library: GL.
Nothing works for me…
I have the canvas on the camera, the z axis, the material and all but I still can’t figure out why I’m unable to see the lines in the gamemode.