Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    Dismiss Notice

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:
    886
    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,326
    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:
    886
    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,050
    Did this work in previous versions?
     
  5. Quatum1000

    Quatum1000

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

    5argon

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

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    886
    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,050
    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:
    886
    (Case 1167675)
     
    LeonhardP likes this.
  10. LeonhardP

    LeonhardP

    Unity Technologies

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

    Quatum1000

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