# OnHierarchyChange()

> Handler for message that is sent when an object or group of objects in the hierarchy changes.

## Definition

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

```csharp
public void OnHierarchyChange()
```

### Remarks

Actions that trigger this message include creating, renaming, reparenting, or destroying objects in the current hierarchy, as well as loading, unloading, renaming, or reordering loaded Scenes. Note that the message is not sent immediately in response to these actions, but rather during the next update of the editor application. Actions taken with objects that have [HideFlags.HideInHierarchy](/engine/6000.6/script-reference/unityengine/hideflags/hideinhierarchy.md) set will not cause this message to be sent, but changing [Object.hideFlags](/engine/6000.6/script-reference/unityengine/object/hideflags.md) will. The OnHierarchyChange() is added to the Unity editor. Adding a new GameObject into the Scene, or changing the position of a GameObject in the Inspector will be observed by OnHierarchyChange(). Similarly, changes to the rotation and scale will be seen. ![EditorWindowOnHierarchyChange (OnHierarchyChange())](/api/media?file=/engine/6000.6/media/images/EditorWindowOnHierarchyChange.gif) *An animation showing how the OnHierarchyChange can be used.* Additional Resources: hierarchyChange The following example script created an [EditorWindow](/engine/6000.6/script-reference/unityeditor/editorwindow.md) that monitors the number of objects and updates whenever the hierarchy changes. Copy it into a file called HierarchyMonitorWindow\.cs and put it in a folder called Editor.

### Examples

```csharp

{code Modules/UIElements/Tests/UIElementsExamples/Assets/EditorWindowCodeExamples/HierarchyMonitorWindow.cs}
```
