docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method DetachChildren

    DetachChildren(EntityManager, 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.

    Declaration
    public static void DetachChildren(this EntityManager em, Entity parent, bool preserveWorldTransform = true)
    Parameters
    Type Name Description
    EntityManager em

    The EntityManager.

    Entity parent

    The entity whose children should be detached.

    bool preserveWorldTransform

    If true, the world-space transform of all child entities will be preserved as closely as possible by setting each entity's LocalTransform component to match its current world-space transform. Slight differences are still possible due to floating-point rounding.

    If false, the childrens' LocalTransform components 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.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the target parent entity does not exist.

    InvalidOperationException

    Thrown if preserveWorldTransform is true, but parent, its children, or its ancestors do not have the required LocalTransform component.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)