Handles. Why do they draw through objects?

Hey,

I’m making a little grid based level editor. I’m drawing a grid using Handles.DrawLine () and it draws through everything which is pretty annoying. Makes navigation pretty hard when trying to build on multiple layers

Is there any way to draw handles that don’t appear through objects?

(Here’s a screenshot)

I’m not sure, but I think handles are always drawn on top of everything else, maybe you could use Line Renderer with a script that is executed in edit mode.

The only thing I know that supports depth is:

Alternatively you may use GL with a shader that has two passes. One for occluded parts, the other for non-occluded ones.

Thanks dude. Yeah debug still showed up through the meshes. Thanks. I’ll try the GL + shader idea

Regarding Debug.DrawLine: Make sure the depth test parameter to true.

Yeah I set it to true. Still rendered through objects.

I understand this post is old but for future viewers, see Unity - Scripting API: Handles.zTest

3 Likes

@ Thank you so much for the post, that saved my butt. What a great feature.

How did you get zTest to work? It does nothing for me, same for this guy: Handles.ztest doesn't work as advertise

1 Like