Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Bug Handles.ztest doesn't work as advertise

Discussion in 'Scripting' started by nsxdavid, May 24, 2021.

  1. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    The docs say Handles.zTest can be used to control the depth pass handling of handles:

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

    I find this not to be true. I can set Handles.zTest to CompareFunction.LessEqual and it's no different than if it is set to CompareFunction.Always. I've tried it on Handles.DrawLine, DrawBezier and DrawWireDisc. None of which respect the depth buffer.

    I do not that if I set it to CompareFunction.Never, then it doesn't draw anything. So it seems like something is going on in there under the hood, just not what one expects.

    Am I missing something or is this a bug?
     
  2. ProFiLeR4100

    ProFiLeR4100

    Joined:
    Dec 27, 2015
    Posts:
    12
    Hello @nsxdavid,
    I've also faced the same problem, did you find a solution?
    Or maybe Unity Devs could help?

    Code (CSharp):
    1. Handles.zTest = UnityEngine.Rendering.CompareFunction.LessEqual;
    2. if (Handles.Button(position, Quaternion.identity, handleSize, pickSize, Handles.SphereHandleCap)) {
    3.     // ...
    4. }
    The highlighted sphere must be hidden, but it remains drawn on screen.
    upload_2022-5-12_13-51-37.png upload_2022-5-12_13-46-20.png

    Editor version: 2022.1.0b14.2951
    Render Pipeline: Built In Render Pipeline

    And also handles are ignoring z depth of each other:
    upload_2022-5-12_14-7-55.png
     
    Last edited: May 12, 2022
  3. ProFiLeR4100

    ProFiLeR4100

    Joined:
    Dec 27, 2015
    Posts:
    12
    Looks like zTest is not working only in Built In Render Pipeline, because here what happens if I use URP.
    upload_2022-5-12_16-16-1.png
     
    trombonaut and t2g4 like this.