- Home /
3d Line Drawing in editor with z-sorting
Hi, I'm trying to draw 3d lines (helpers) in the editor window. It works with both Handles.DrawLine and Gizmos.DrawLine, except that in both cases the lines are drawn on top of the meshes geometry, without any z-sorting.
Does anybody knows how to draw lines with z-sorting enabled so that they get hidden by the level geometry if they are behind it?
Thanks
I'm using Unity 3.5.7, and it looks like gizmo lines have changed since you asked this question. They now inter-sort with the geometry, showing solid when in front of geometry and faint when behind. (I'm trying to figure out how to do what you didn't want and make the lines always appear on top.)
Answer by skovacs1 · Oct 07, 2010 at 06:41 PM
I don't think you really can and have it only in the editor's scene view.
Gizmos, Handles and Debug drawing all takes place on top of regular rendering of the scene as overlays. There is no way that I can find to get them into the same rendering queue as the regular render of the scene.
To create objects that are rendered as part of the scene's normal render queue, they would either have to be GameObjects in your scene or you would have to provide specifications for their drawing. One way to specify objects to be drawn is Graphics.DrawMesh or DrawMeshNow. You could fiddle with the GL functions, but those are very likely not to give you what you want. Any objects created in the scene view this way will also be rendered in the game view and I have found no way to prevent them from showing up in both.
You might try looking into Editor.OnSceneGUI to get things to happen only in the scene view, but I am fairly certain that anything put there would be subject to the limitations of the above methods.
Thanks for the answer skovacs. I guess I can manage what I want through Draw$$anonymous$$esh indeed; it's remarkably less convenient though :)