- Home /
Draw a line in Game View?
As I know to draw a line in Scene View is easy to use Debug.DrawLine() function,
But I want to draw lines in Game View,How to do that?
Can you use a line-renderer? Or do you rely on your lines being always one pixel wide?
If this is for Debug purposes, and you just want the lines drawn by Debug.DrawLine to be visible, you can enable them by hitting the "Gizmos"-button in the top right corner of the window.
If this is for use in the final game/app, then you need to use a LineRenderer, as @syclamoth suggested.
Or, if you have a few bucks to spare, check out Vectrocity, which has a lot of line drawing functionality custom tailored for exactly this purpose.
Thanks,and I found a document http://unity3d.com/support/documentation/ScriptReference/GL.html
I'd have suggested that, but it's not exactly simple to use... I also wasn't sure if you were using Unity Pro or not.
Answer by Ev · Oct 27, 2013 at 09:12 PM
Try this tutorial:
http://www.everyday3d.com/blog/index.php/2010/03/15/3-ways-to-draw-3d-lines-in-unity3d/
The link was good just a week ago, so I'd wait a day and see if the site comes up again.
Answer by Marnix · Oct 05, 2011 at 07:54 AM
Please check the search of this Qota, before posting a question.
You can find your answer easily in the first 3 results: http://answers.unity3d.com/search.html?redirect=search%2Fsearch&q=draw+line
http://answers.unity3d.com/questions/17863/line-render-draw-line.html
http://answers.unity3d.com/questions/8338/how-to-draw-a-line-using-script.html
So, use a line renderer, use GL
-class. Or use something from the forum. I have seen a couple of techniques and packages that handle it for you, but mostly not in the free version if you are looking for 1px wide lines.
Of course, this Q is now the first Google result - so everyone comes here to find a list of links elsewhere.
Why does an "answer" with no direct answer have so many upvotes? This question shows up in google, so upvoting something that starts with "Please check the search" is really silly. If this specific instance of this question is considered a duplicate, close it and make a proper redirect to one that has a good answer ins$$anonymous$$d of wasting the answers.unity3d.com space with non-answers..
Answer by Cherno · May 01, 2016 at 07:06 PM
This solution uses OnGUI to draw a line of variable width:
Answer by 2FlyDreams · Dec 05, 2013 at 03:17 PM
You can try "Dream Paint" ( Asset Store Link ). It allows to draw 2D and 3D primitives in game and in editor, and many others features ...