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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Disable selection of parented objects like LODs

Discussion in 'Editor & General Support' started by ToastyJ, May 20, 2022.

  1. ToastyJ

    ToastyJ

    Joined:
    Oct 8, 2020
    Posts:
    7
    Does anybody know of a way to make parented objects in the scene view unclickable. Something that is scene independent.

    I know you can do this in the hierarchy panel, with the hand icon, but this isn't a good solution when building a big level as you have to manually disable the child objects every time. And then for the next level you have to do this all over again.

    Example... a tree prefab with 3 LOD's..... when its selected, it selects LOD0. I never want this to happen.

    In 3DS/Maya it's called freezing an object.
     
  2. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    637
    You can write a custom editor script that listens to selectionChanged , just add a callback in a static method with the [InitializeOnLoadMethod] Attribute above it.
    Then a simple check, if the mouse is over the scene view window and if the new selected GameObject has an LOD-Component in it's parents -> select the parent with the LOD-Component instead.
    MouseOverWindow method link.

    Otherwise you could try to use the SelectionBaseAttribute.
     
    ExtraCat likes this.
  3. ToastyJ

    ToastyJ

    Joined:
    Oct 8, 2020
    Posts:
    7
    Thanks for the reply! I'll give this a go!.
     
  4. PixelFireXY

    PixelFireXY

    Joined:
    Nov 2, 2011
    Posts:
    53
    Sorry for the necro but I made a script for who needs it. Just place the script inside the Editor folder and you are good to go.

    https://pastebin.com/632Ctm4b

    Also is disabled by default for performance reasons, you enable it by clicking on "Tools/LOD Selection/Toggle LOD Parent Selection"