HideFlags.HideInHierarchy not updating hierarchy in Edit-mode
Hey there guys.
So here is the deal:
I made a window to allow me to quickly hide and unhide objects in my hierarchy. Here it is:
Yeah.... I'm making a MLG-style-game. Dont judge me :P
Alright. So to hide my objects I use this:
foreach (GameObject effect in GameObject.FindGameObjectsWithTag("Effect")) {
effect.SetActive (false);
if (effectsVisible)
effect.hideFlags = HideFlags.None;
else
effect.hideFlags = HideFlags.HideInHierarchy;
effect.SetActive (true);
Repaint ();
EditorApplication.RepaintHierarchyWindow ();
}
This is the "Effects visible" button. This should work but... it doesnt really. The hierarchyjust doesnt update when I press the button, It does however update when I close and reopen it. Then my Hideflags are set correctly.
Is there a way to reload the hierarchy via script or to set the hideflags in a way that automatically updates the hierarchy?
Thanks in advance guys :D
Answer by Rodiaz89 · Dec 03, 2016 at 09:38 AM
I had the same issue @Brullix3000
Try adding this after the RepaintHierarchyWindow
EditorApplication.DirtyHierarchyWindowSorting();
Thanks! Would one of you $$anonymous$$d filing a bug report on this so it gets to the Asset $$anonymous$$anagement $$anonymous$$m?
Ah right sorry! There was another thread with a similar problem, too :)
Can anyone confirm if this is how to do this for an Editor script? I can't get the hideflags to work in the OnInspectorGUI in an Editor script.
Answer by Quatum1000 · Jul 24, 2017 at 05:18 PM
In my case the only way in 2017.b10 is to use after GameObject.hideFlags;
#if UNITY_EDITOR
try { EditorApplication.DirtyHierarchyWindowSorting(); } catch { }
#endif
Otherwise if the script will be enabled and disabled during any reason I got an Fatal Reference Error spam.
Answer by Adam-Mechtley · Nov 17, 2016 at 09:04 AM
I messed with this a bit and it actually looks like a bug to me. Could you submit a bug report please?
Alright will do.
Did you find a workaround or will I just have to deal with it?
I did not, but if you file a bug it should end up with the Asset $$anonymous$$anagement $$anonymous$$m, who would be in a better position to let you know if there's a workaround, if this behavior is somehow expected, etc.
Alright thanks m8. I sent a report. Let's see what they have to say :)
Your answer
Follow this Question
Related Questions
HideFlags and Prefabs 1 Answer
Game Manager loses reference to GUIText gameObject on a new scene 1 Answer
My collectable objects don't respond like they should after calling a coroutine for the first time? 0 Answers
Vector3.Lerp in update, how stop? 1 Answer
HideAndDontSave disables OnDestroy 0 Answers