# SetParent

> Sets the parent node of a hierarchy node.

## Definition

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

## SetParent(HierarchyNode, HierarchyNode)

Sets the parent node of a hierarchy node.

```csharp
public bool SetParent(in HierarchyNode node, in HierarchyNode parent)
```

### Parameters

**** (\[HierarchyNode]\(/engine/6000.6/script-reference/unity/hierarchy/hierarchynode)): The hierarchy node to set a parent for.**** (\[HierarchyNode]\(/engine/6000.6/script-reference/unity/hierarchy/hierarchynode)): The hierarchy node to set as the parent node.

### Returns

| Type                                                          | Description                                                        |
| ------------------------------------------------------------- | ------------------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the command was appended to the list, `false` otherwise. |

## SetParent(HierarchyNode, HierarchyNode, int)

Sets the parent node of a hierarchy node.

```csharp
public bool SetParent(in HierarchyNode node, in HierarchyNode parent, int index)
```

### Parameters

**** (\[HierarchyNode]\(/engine/6000.6/script-reference/unity/hierarchy/hierarchynode)): The hierarchy node.**** (\[HierarchyNode]\(/engine/6000.6/script-reference/unity/hierarchy/hierarchynode)): The hierarchy node to set as a parent.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index at which to insert the node in the parent's children list.

### Returns

| Type                                                          | Description                                                        |
| ------------------------------------------------------------- | ------------------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the command was appended to the list, `false` otherwise. |

### Remarks

The index maximum value is the parent's child count, or child count minus one if moving within the same parent.
