• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Ben 14 · Oct 07, 2010 at 04:13 PM · editorlinegizmosdrawinghandles

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yoyo · Nov 01, 2013 at 11:50 PM 0
Share

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.)

2 Replies

· Add your reply
  • Sort: 
avatar image
2

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ben 14 · Oct 07, 2010 at 07:31 PM 0
Share

Thanks for the answer skovacs. I guess I can manage what I want through Draw$$anonymous$$esh indeed; it's remarkably less convenient though :)

avatar image
2

Answer by JatsArts · Jan 28, 2018 at 04:26 PM

https://docs.unity3d.com/ScriptReference/Handles-zTest.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Editor Windows : Help required 1 Answer

Select object by selecting gizmo or handle? 1 Answer

Showing Handles in the Game View 1 Answer

What is the best way to use the Handles class to create custom gizmos. 1 Answer

Editor 3D tools with depth 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges