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?
asked Oct 07 '10 at 04:13 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.
answered Oct 07 '10 at 06:41 PM