Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetParent

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

Definition

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

SetParent(HierarchyNode, HierarchyNode)

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

Parameters

The hierarchy node to set a parent for.

The hierarchy node to set as the parent node.

Returns

Type

Description

bool
true
if the command was appended to the list,
false
otherwise.

SetParent(HierarchyNode, HierarchyNode, int)

Sets the parent node of a hierarchy node.
public bool 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.

Returns

Type

Description

bool
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.