# GetOrCreateNode

> Gets or creates the HierarchyNode that corresponds to the specified GameObject EntityId.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Hierarchy.Editor](/engine/6000.6/script-reference/unity/hierarchy/editor.md)
* **Assembly:** UnityEditor

## GetOrCreateNode(EntityId)

Gets or creates the [HierarchyNode](/engine/6000.6/script-reference/unity/hierarchy/hierarchynode.md) that corresponds to the specified [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md)[EntityId](/engine/6000.6/script-reference/unityengine/entityid.md).

```csharp
public HierarchyNode GetOrCreateNode(EntityId entityId)
```

### Parameters

**** (\[EntityId]\(/engine/6000.6/script-reference/unityengine/entityid)): The [EntityId](/engine/6000.6/script-reference/unityengine/entityid.md) of the [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) to get the [HierarchyNode](/engine/6000.6/script-reference/unity/hierarchy/hierarchynode.md) for.

### Returns

| Type                                                                              | Description                                                                                                                                                                                  |
| --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [HierarchyNode](/engine/6000.6/script-reference/unity/hierarchy/hierarchynode.md) | The [HierarchyNode](/engine/6000.6/script-reference/unity/hierarchy/hierarchynode.md) that corresponds to the specified [EntityId](/engine/6000.6/script-reference/unityengine/entityid.md). |

### Remarks

If the node doesn't exist, this method returns a node that represents the [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) but that doesn't yet exist in the hierarchy. To query the [Hierarchy](/engine/6000.6/script-reference/unity/hierarchy/hierarchy.md) about this node, update the hierarchy first.

## GetOrCreateNode(GameObject)

Gets or creates the [HierarchyNode](/engine/6000.6/script-reference/unity/hierarchy/hierarchynode.md) that corresponds to the specified [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md).

```csharp
public HierarchyNode GetOrCreateNode(GameObject gameObject)
```

### Parameters

**** (\[GameObject]\(/engine/6000.6/script-reference/unityengine/gameobject)): The [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) to get the [HierarchyNode](/engine/6000.6/script-reference/unity/hierarchy/hierarchynode.md) for.

### Returns

| Type                                                                              | Description                                                                                                                                                                                      |
| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [HierarchyNode](/engine/6000.6/script-reference/unity/hierarchy/hierarchynode.md) | The [HierarchyNode](/engine/6000.6/script-reference/unity/hierarchy/hierarchynode.md) that corresponds to the specified [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md). |

### Remarks

If the node doesn't exist, this method returns a node that represents the [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) but that doesn't yet exist in the Hierarchy. To query the [Hierarchy](/engine/6000.6/script-reference/unity/hierarchy/hierarchy.md) about this node, update the hierarchy first.
