# DetachChildren()

> Unparents all of the target object's children.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public void DetachChildren()
```

### Remarks

Each immediate child is moved to the root-level, preserving their internal hierarchies. This is useful if you want to destroy the root of a hierarchy without destroying the children, and is more efficient than unparenting each child individually.

Additional Resources: [Transform.parent](/engine/6000.5/script-reference/unityengine/transform/parent.md) to detach/change the parent of a single transform.

### Examples

```csharp
{code Tests/EditModeAndPlayModeTests/Transform/Assets/DocumentationExamples/DocExamples_TransformHierarchy.cs#transform-detachchildren-example}
```
