docs.unity.cn
    Show / Hide Table of Contents

    Method MoveComponent

    MoveComponent<T>(EntityManager, Entity, Entity)

    Move the given component on the source entity to another destination entity.

    Declaration
    public static void MoveComponent<T>(this EntityManager manager, Entity src, Entity dst)
        where T : class, IComponentData, new()
    Parameters
    Type Name Description
    EntityManager manager

    This entity manager.

    Entity src

    The Entity the managed component will be removed from

    Entity dst

    The Entity the managed component will be added to

    Type Parameters
    Name Description
    T

    The managed component type.

    Remarks

    If the source and destination entity are identical, no operation is performed.

    This operation seems similar to

    value = GetComponentData<T>(src); AddComponentData(dst, value) RemoveComponent<T>(src)

    But for managed components which implement IDisposable, calling RemoveComponent will invoke Dispose() on the component value, leaving the destination entity with an uninitialized object.``` This operation ensures the component is properly moved over.

    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Wednesday, June 21, 2023