Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Hide object in Hierarchy, but still allow selection

Discussion in 'Scripting' started by joshcamas, Jun 15, 2018.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    281
    Hello friends :)

    I have an object that I want to hide from the hierarchy, but I still want to be able to select it (or at the very least, somehow detect clicking it). Is there a way to do this? Thanks!

    EDIT: I tried adding a collider to the object, then on scene click, shoot a ray from the camera, and it works.. ALMOST? I can detect right mouse up, but not left mouse up...

    Also, (not really related but I didnt want to make another post) is it possible to make it look like I'm selecting a gameobject, when in the inspector it's showing another selected object?

    Josh
     
    Last edited: Jun 15, 2018
  2. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    352
    Regarding your first question:
    Do you want to hide it in the hierarchy structure of the unity editor? Or do you just want to hide it?
    If you just want to hide that object as well as its child objects, add a CanvasGroup component to the parent and set the alpha value to zero.

    second question:
    Really not sure what you want to achieve... maybe you can tell your exact use case.
     
    joshcamas likes this.
  3. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    281
    I simply want to make the object hidden in the structure.

    My goal for this is I want a clickable mesh in the editor (that wont be saved or shown in hierarchy) that upon clicking it, looks like I'm editing that mesh but in truth I'm editing a scriptable object. (Object in inspector in scriptable object).

    Clearly a super duper strange request, I'm basically making a system that keeps character/item spawn points separate from the scene data, but I want to make it have the same functionality as a normal gameobject in the editor (aka clickable to edit)
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,043
    I believe you're looking for this.

    https://docs.unity3d.com/ScriptReference/HideFlags.HideInHierarchy.html

    But I have to say, please don't do this for any asset you intend on selling on the asset store. The first time I removed an asset I had purchased from my project that had placed a hidden object in my scene hierarchy it took me several hours to figure out where the hell these missing components warnings were coming from and figure out how to remove the object. Beyond frustrating.
     
  5. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    281
    Yes, that's what I've tried... sadly, this means the user cannot select the object.