- Home /
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);
}
}
}
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.
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
I tried to do as you said but it's only crashing Unity. Have you got any sample you could share with us? :)
Worked well for me!! Thanks a lot hehe :) (Unity 4.3.1f1)
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);
}
}
Your answer
Follow this Question
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