Search Unity

Question Possible to disable Hierarchy Selection when selecting scene object?

Discussion in 'Scripting' started by jessee03, Jan 10, 2023.

  1. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    Is it possible to code a editor script to disable Hierarchy Selection when selecting scene object? So my Hierarchy has a lot of objects, when I select certain objects in my scene it selects the object in the Hierarchy as well, which causes me to have to scroll through all these objects to close the sub empty gameobject that it exists in. This gets very annoying. I still want the object to be selected and show inspector settings, just not to effect the Hierarchy at all. But I do want it so when I scroll through the Hierarchy that it will show the object selected. Just dont want the Hierarchy to automatically jump to the objects location in the Hierarchy. If that makes any sense.
     
    Last edited: Jan 10, 2023
  2. oscarAbraham

    oscarAbraham

    Joined:
    Jan 7, 2013
    Posts:
    431
    There's a Lock toggle for the Hierarchy window similar to the Lock toggle in the inspector window. If you lock it, the Hierarchy will no longer scroll when selection changes.
     
    halley and Bunny83 like this.
  3. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    Where is this option? The only thing I see is the pointer icon, which is not the option I want. I'm not trying to ignore scene selection. I want to be able to select anything in the scene, then make it so the Hierarchy view doesn't jump to the object in the Hierarchy. When you select an object in the scene it auto jumps to the object in the Hierarchy, I want to disable this jump.
     
  4. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,439
    Just like the Inspector can be locked with the padlock and it won't follow the selection, the Hierarchy can also be locked with its own padlock. The selection changes, but the view won't scroll or expand to see the change. These padlocks are to the right of the Inspector or Hierarchy tab.



    Edit: You can affect the Inspector lock by code, but not sure about Hierarchy. Some of this is not exposed in the API, and you might need to use reflection to find the option. Then it would be a matter of capturing the current Selection and restoring it when you're done poking around.
     
    Last edited: Jan 10, 2023
  5. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    Awesome had no idea that option was there. Thank you! Works how I want