Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Bug? Toggling Gizmos visibility off doesn't prevent selection of game objects

Discussion in 'Editor & General Support' started by dgoyette, Jan 30, 2021.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    3,995
    Something fairly annoying. If you disable Gizmos by toggling the Toggle Gizmos button, it doesn't prevent selection of the gizmos. For example, here's a game object with a box collider, no renderer, and a script that draws a gizmo:

    upload_2021-1-30_16-22-3.png

    If I click on this yellow box, it will select the object. If I remove the script with the OnDrawGizmos method on it (thus making the box disappear), I can no longer select the object by clicking in/around this area. This confirms that you can't select a rendererless, gizmozless collider by clicking within its volume.

    Now, instead of removing the script, I toggle the Show Gizmos button:

    upload_2021-1-30_16-20-19.png

    The gizmo goes away:

    upload_2021-1-30_16-23-51.png

    However, if I click in this area, it selects the object, even though it's currently not visible at all. This is really confusing when you're trying to click something, and an invisible object keeps getting selected.

    This seems like a bug? I can't think of a really convincing reason why someone would want to hide gizmos but still want to be able to click on all these invisible gizmos as they navigate the scene.
     
    PraetorBlue likes this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,167
    Interesting. It seems related to the DrawCube... a DrawWireCube does not have the behavior, but it might if you are able to nail the invisible line where it WOULD be if enabled.

    I did find that if you go into the details of the gizmos you can turn off JUST the gizmos for that one script. Didn't even know that selection was possible!

    I made a fresh script called ODG to test this and it shows up in the list along with my other gizmo-drawing scripts. Turning off ODG on my cube prevented its selection, even with DrawCube.

    Screen Shot 2021-01-30 at 12.18.21 PM.png
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    3,995
    That's interesting. I'm aware of the behavior of unchecking specific scripts in the Gizmos menu (which is equivalent to collapsing that component on any game object), but it's quite interesting that doing so causes it to be unselectable by clicking in the Scene view. That's pretty interesting, and surprising. It implies that whatever Unity does when disabling all gizmos is slightly different than what it does when disabling individual gizmos. Which maybe gives me hope that they can fix the behavior I'm considering a bug...

    FWIW, I'm using DrawMesh in this gizmo. If I use DrawWireMesh instead, you're correct that it becomes pretty much unselectable, which isn't really what I want, since now I can't select the object when I actually want to click on it and select it. :)

    Anyway, good points here. I think the takeaway is that disabling a single component causes that components gizmo to "do the right thing", which disabling all gizmos at once causes the gizmos to "do the wrong thing", and I should submit a bug report stating that disabling all gizmos should work the way it does when disabling individual gizmos.