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
2
Question by Aubrey-Falconer · Mar 02, 2011 at 05:19 AM · editortransformeditor-scriptinghideflags

HideFlags on children of visible objects.

No matter what I try, I can't get HideFlags.HideInHierarchy to perform like I expect it to. Should I be able to hide objects which are the children of visible objects? Blockquote

class HideFlagManager extends EditorWindow {

 @MenuItem("Whirld/Editor HideFlags Manager")

 static function Init() {

     var window = GetWindow(HideFlagManager);

     //window.autoRepaintOnSceneChange = true;

     window.Show();

 }



 function OnSelectionChange() {

     Repaint();

 }



 function OnGUI() {



     if(Selection.activeGameObject) {

         if(GUILayout.Button("Hide Selected")) {

             Selection.activeGameObject.hideFlags = HideFlags.HideInHierarchy;

             EditorUtility.SetDirty(Selection.activeGameObject);

         }

         if(GUILayout.Button("Hide Children of Selected")) {

             SetFlags(Selection.activeGameObject.transform, HideFlags.HideInHierarchy);

             EditorUtility.SetDirty(Selection.activeGameObject);

         }

         if(GUILayout.Button("Show Children of Selected")) {

             SetFlags(Selection.activeGameObject.transform, 0);

         }

     }

     else {

         GUILayout.Label("\n(Select a GameObject to enable full functionality)\n");

     }

     if(GUILayout.Button("Unhide All")) {

         for (var go : GameObject in Resources.FindObjectsOfTypeAll(GameObject)) {

             Debug.Log(go.name);

             if(go.hideFlags != HideFlags.HideAndDontSave) {

                 go.hideFlags = 0;

                 EditorUtility.SetDirty(go);

             }

         }

     }

 }



 function SetFlags(tr : Transform, hf : HideFlags) {

     for (var child : Transform in tr) {

         child.gameObject.hideFlags = HideFlags.HideInHierarchy;

         EditorUtility.SetDirty(child.gameObject);

         //SetFlags(child, hf);

     }

 }

}

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Jake-L · Mar 02, 2011 at 07:15 AM

You're not alone ;) But HideFlags are bugged at the moment (Unity 3.2). Didn't checked 3.3 yet, but there wasn't anything about HideFlags in the Release Notes.

Comment
Add comment · Show 1 · Share
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 Aubrey-Falconer · Mar 02, 2011 at 03:35 PM 0
Share

Thanks! I just submitted a bug report.

avatar image
1

Answer by Davo · Apr 15, 2011 at 11:22 PM

One work around for now is if you call gameObject.active = false, then GameObject.active = true, it forces that entry in the Hierachy window to update (and therefore hide). I wrote a script similar to yours recently and thats how I made it work

Comment
Add comment · Show 2 · Share
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 hardwire · Jun 14, 2011 at 12:26 PM 0
Share

I tried to do as you said but it's only crashing Unity. Have you got any sample you could share with us? :)

avatar image JanWosnitza · Mar 06, 2014 at 04:16 PM 0
Share

Worked well for me!! Thanks a lot hehe :) (Unity 4.3.1f1)

avatar image
0

Answer by Raimi · Sep 14, 2014 at 05:39 PM

         if(showHierarchy)
         {
             foreach(Transform t in transform)
             {
                 gameObject.SetActive(false);
                 t.hideFlags = HideFlags.None;
                 gameObject.SetActive(true);
                 
             }
         }else{
             foreach(Transform t in transform)
             {
                 gameObject.SetActive(false);
                 t.hideFlags = HideFlags.HideInHierarchy;
                 gameObject.SetActive(true);
                 
             }
         }
Comment
Add comment · Share
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

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

2 People are following this question.

avatar image avatar image

Related Questions

Updating object on inspector value changes in editor 1 Answer

How to get notification of moving a GameObject in the hierachy when editing the scene? 1 Answer

How to check if a key is down in editor script 2 Answers

Hide Object in Hierarchy Window 3 Answers

Access Monobehavior Instance from Static Function of Editor Script 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