x


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);

        }

    }

}
more ▼

asked Mar 02 '11 at 05:19 AM

Aubrey Falconer gravatar image

Aubrey Falconer
657 45 53 68

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Mar 02 '11 at 07:15 AM

Jake L. gravatar image

Jake L.
943 5 6 22

Thanks! I just submitted a bug report.

Mar 02 '11 at 03:35 PM Aubrey Falconer
(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Apr 15 '11 at 11:22 PM

Davo gravatar image

Davo
14 2

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

Jun 14 '11 at 12:26 PM hardwire
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5076
x1673
x1279
x348
x9

asked: Mar 02 '11 at 05:19 AM

Seen: 1508 times

Last Updated: Jun 14 '11 at 12:26 PM