Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by thrmotta · Jun 09, 2014 at 06:08 PM · c#editorhierarchyidehideflags

How to hide parent in Hierarchy and maintain child?

Hi all,

Ive been doing some research on hiding objects in the Hierarchy IDE, which now works fine as long as the object doesnt have a hierarchy of its own.

In another words, lets say I have an Object Tree, which have a child Leaf. Aside from that, lets say I have some Light at the scene. In this case, if I choose Light, I want everything else to be hiden, which is working at the moment. If I choose Leaf, then both the Leaf AND the Tree gets displayed, which is not what I would expect. If I choose Tree, then both the Tree AND the Leaf gets hidden, which also is not working properly. The proper way of it to work would be to hide everything that is not what I selected.

This is what my code looks like:

 public static void HideObjects<T>( int choice )
 {
     object[] allObjects = FindObjectsOfTypeAll(typeof(GameObject));    
     foreach(object currObj in allObjects )
     {
         GameObject currGo = (GameObject) currObj;
 
         Component[] listOfComponents = currGo.GetComponentsInChildren (typeof(Component));
         for( int i = 0; i < listOfComponents.Length; i++ )
         {
             currGo.hideFlags = HideFlags.HideInHierarchy;     
             if ( listOfComponents[i].GetType () == typeof(T) && mouseSelected == choice )
                      currGo.hideFlags = HideFlags.None;
             else
                      currGo.hideFlags = HideFlags.HideInHierarchy;   
         }
         
         currGo.SetActive (false);
         currGo.SetActive (true); 
     }
  }

What else can I do here in order to hide only a specific object even though this object is in an hierarchy? How to hide a parent without hiding its child or how to hide a child without hiding its parent?

Thank you all!

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PouletFrit · Jun 09, 2014 at 06:44 PM 0
Share

Depends on what you mean by hiding... but you could disable the renderer component of the object(s) you wish to hide

avatar image IvovdMarel · Jun 09, 2014 at 06:46 PM 0
Share

In your description you mention you can't show something while hiding it's parent or hide something while showing its child. That makes sense to me actually. If I want to see a leaf, of course the parent tree will need to be visible as well (a child is never visible if it's parent is not).

The last question you ask, hiding a child without hiding it's parent, SHOULD be possible but I'm not sure if you tried that.

avatar image thrmotta · Jun 09, 2014 at 06:52 PM 0
Share

@PouletFrit, I still want to render it. By hiding I mean to only hide its name in Hierarchy IDE, much like what you get when you do a search in Hierarchy ID$$anonymous$$

@Ivov$$anonymous$$arel, Im actually pretty new to Unity, so I really cant think of a different approach then the one tried here.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Cant hide anything in Hierarchy IDE 2 Answers

Does this kind of Visual Programming IDE (or IDE plugin) focused on enhancing the experienced programmer productivity when dealing with the creating of complex Systems already exists? 0 Answers

Detecting moment when GameObiect is created in hierarchy. 1 Answer

How to switch back the Hierarchy window to scene from prefab? 0 Answers

Multiple Cars not working 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges