g.gameObject.hideFlags = HideFlags.HideInHierarchy; does not update the hierarchy.
Didn’t found any command to redraw the Hierarchy. Only recompiling a script updates the Hierarchy. I’m doing here anything wrong?
Unhide works well.
using UnityEditor;
using UnityEngine;
public class UnHideInvisibleGameObjects : MonoBehaviour {
[MenuItem("Tools/Unhide All GameObject In Hierarchy")]
static void UnhideGameObjectsInHierarchy() {
foreach (var t in GameObject.FindObjectsOfType<Transform>()) {
if (t.gameObject.hideFlags != HideFlags.None) {
t.gameObject.hideFlags = HideFlags.None;
Debug.Log("Unhide Gameobject : " + t.gameObject.name + "");
}
}
}
[MenuItem("Tools/")]
[MenuItem("Tools/Hide Selected Gameobject In Hierarchy")]
static void HideSelectedGameObjectsInHierarchy() {
var gs = Selection.gameObjects;
foreach (var g in gs) {
if (g.gameObject.hideFlags == HideFlags.None) {
g.gameObject.hideFlags = HideFlags.HideInHierarchy;
//var ac = g.gameObject.activeSelf;
//g.gameObject.SetActive(true);
//g.gameObject.SetActive(ac);
Debug.Log("Hide Gameobject : " + g.gameObject.name + "");
}
}
}
}
also UnityEditorInternal.InternalEditorUtility.HierarchyWindowDragByID(0, UnityEditorInternal.InternalEditorUtility.HierarchyDropMode.kHierarchySearchActive, null, false);
does not work.
Could you please submit a bug report? That’s the safest way to receive an answer to this problem in this case and if it turns out to be an issue it will already be in the appropriate pipeline.