Documentation

Unity Engine

Unity Engine

DetachChildren(Entity, bool)

Break the parent/child links between the target entity and all of its children. Each child entity becomes the root of a new hierarchy.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: Unity.Entities
  • Assembly: UnityEngine.EntitiesModule
public void DetachChildren(Entity parent, bool preserveWorldTransform = true)

Parameters

parent

The entity whose children should be detached.

preserveWorldTransform

If true, the world-space transform of all child entities will be preserved as closely as possible to match its current world-space transform. Slight differences are still possible due to floating-point rounding.
If false, the childrens' transforms will not be modified. However, the existing values will now be relative to world-space instead of
parent
; this may cause a significant instantaneous change in their world-space transforms.

Remarks

This is effectively the same as calling SetParent(child, Entity.Null, preserveWorldTransform) on all of the target entity's children, but is potentially more efficient.
This function must not be used from an ExclusiveEntityTransaction context. Manipulating transform hierarchies from worker threads is not safe.