Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetParent

Sets the parent of a hierarchy node.
Read time 1 minuteLast updated 14 days ago

Definition

  • Type: Method
  • Namespace: Unity.Hierarchy
  • Assembly: UnityEngine.HierarchyCoreModule

SetParent(HierarchyNode, HierarchyNode)

Sets the parent of a hierarchy node.
public void SetParent(in HierarchyNode node, in HierarchyNode parent)

Parameters

The hierarchy node.

The hierarchy node to set as a parent.

SetParent(HierarchyNode, HierarchyNode, int)

Sets the parent of a hierarchy node.
public void SetParent(in HierarchyNode node, in HierarchyNode parent, int index)

Parameters

The hierarchy node.

The hierarchy node to set as a parent.

index

The index at which to insert the node in the parent's children list.

Remarks

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