# RepaintHierarchyWindow()

> Can be used to ensure repaint of the HierarchyWindow.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.3/script-reference/unityeditor.md)
* **Assembly:** UnityEditor

```csharp
public static void RepaintHierarchyWindow()
```

### Remarks

Use [EditorApplication.RepaintHierarchyWindow](/engine/6000.3/script-reference/unityeditor/editorapplication/repainthierarchywindow.md) to refresh the Hierarchy window when changes to GameObjects, such as names, icons, or tags, are not automatically reflected in the Hierarchy window. [EditorApplication.RepaintHierarchyWindow](/engine/6000.3/script-reference/unityeditor/editorapplication/repainthierarchywindow.md) can be useful when it is used with custom Editor tools or extensions that dynamically alter GameObject properties. Avoid frequent calls in a performance-critical context, because [EditorApplication.RepaintHierarchyWindow](/engine/6000.3/script-reference/unityeditor/editorapplication/repainthierarchywindow.md) might negatively affect Editor performance. This method must be used in the Unity Editor and it requires the [UnityEditor](/engine/6000.3/script-reference/unityeditor.md) namespace. Typically, you combine it with [EditorApplication.hierarchyChanged](/engine/6000.3/script-reference/unityeditor/editorapplication/hierarchychanged.md) or custom events to ensure UI consistency. Not applicable at runtime since it’s Editor-only. Additional Resources: [EditorApplication.HierarchyWindowItemCallback](/engine/6000.3/script-reference/unityeditor/editorapplication/hierarchywindowitemcallback.md), [EditorApplication.hierarchyWindowItemOnGUI](/engine/6000.3/script-reference/unityeditor/editorapplication/hierarchywindowitemongui.md).

### Examples

```csharp
using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
public class CustomHierarchyStyling
{
    static CustomHierarchyStyling()
    {
        // Register a callback to draw custom icons in the Hierarchy.
        EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyGUI;
        // Repaint the Hierarchy window when the tag changes to reflect icon updates
        EditorApplication.hierarchyChanged += () => EditorApplication.RepaintHierarchyWindow();
    }

    static void OnHierarchyGUI(int instanceID, Rect selectionRect)
    {
        GameObject obj = EditorUtility.InstanceIDToObject(instanceID) as GameObject;

        //Add a tag named "Special" to the GameObject to display the custom icon
        if (obj != null && obj.CompareTag("Special"))
        {
        // Draw a custom icon on the left side of the GameObject in the Hierarchy
            Rect iconRect = new Rect(selectionRect.x - 20, selectionRect.y, 18, 18);
            GUI.Label(iconRect, EditorGUIUtility.IconContent("d_Favorite"));
        }
    }
}
```
