Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

BUG? - g.gameObject.hideFlags = HideFlags.HideInHierarchy does nut update hierarchy

Discussion in '2019.2 Beta' started by Quatum1000, Jul 2, 2019.

  1. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    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.

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3.  
    4. public class UnHideInvisibleGameObjects : MonoBehaviour {
    5.     [MenuItem("Tools/Unhide All GameObject In Hierarchy")]
    6.     static void UnhideGameObjectsInHierarchy() {
    7.         foreach (var t in GameObject.FindObjectsOfType<Transform>()) {
    8.             if (t.gameObject.hideFlags != HideFlags.None) {
    9.                 t.gameObject.hideFlags = HideFlags.None;
    10.                 Debug.Log("Unhide Gameobject : " + t.gameObject.name + "");
    11.             }
    12.         }
    13.     }
    14.     [MenuItem("Tools/")]
    15.  
    16.     [MenuItem("Tools/Hide Selected Gameobject In Hierarchy")]
    17.     static void HideSelectedGameObjectsInHierarchy() {
    18.         var gs = Selection.gameObjects;
    19.         foreach (var g in gs) {
    20.             if (g.gameObject.hideFlags == HideFlags.None) {
    21.                 g.gameObject.hideFlags = HideFlags.HideInHierarchy;
    22.            
    23.                 //var ac = g.gameObject.activeSelf;
    24.                 //g.gameObject.SetActive(true);
    25.                 //g.gameObject.SetActive(ac);
    26.  
    27.                 Debug.Log("Hide Gameobject : " + g.gameObject.name + "");
    28.             }
    29.         }
    30.     }
    31. }
     
    Last edited: Jul 2, 2019
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,650
    I know of this method, that redraws just every view, perhaps as a workaround:
    Code (CSharp):
    1. UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
     
  3. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Thanks, tried it but does not work for any reason.
    Seems the internal hierarchy display array does not receive the changes are made on a gameobject.
     
  4. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,143
    Did this work in previous versions?
     
  5. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Does not work in 2019.1.8f1 also.
     
  6. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,556
    How about
    EditorApplication.RepaintHierarchyWindow();
    ?
     
  7. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Thanks, but nope!

    also
    UnityEditorInternal.InternalEditorUtility.HierarchyWindowDragByID(0, UnityEditorInternal.InternalEditorUtility.HierarchyDropMode.kHierarchySearchActive, null, false);

    does not work.
     
  8. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,143
    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.
     
  9. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    (Case 1167675)
     
    LeonhardP likes this.
  10. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,143
  11. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    LeonhardP likes this.