docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method MoveComponent

    MoveComponent<T>(EntityCommandBuffer, Entity, Entity)

    Records a command to safely move a managed component (and its current value) from one entity to another

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

    This entity command buffer.

    Entity src

    The entity whose T component should be moved to dst. This entity must have a component of type T at playback time.

    Entity dst

    The Entity the managed component will be added to. If this entity already has T with a different value than src, the existing value will be removed and disposed before the new value is assigned.

    Type Parameters
    Name Description
    T

    The type of component to move. Must be a managed type.

    Remarks

    At playback, this command throws an error if this entity is destroyed before playback, if this entity is still deferred, or adding this componentType makes the archetype too large.

    Exceptions
    Type Condition
    NullReferenceException

    Throws if an Allocator was not passed in when the EntityCommandBuffer was created.

    InvalidOperationException

    Throws if this EntityCommandBuffer has already been played back.

    ArgumentException

    Throws if src does not have component T at playback time.

    In This Article
    Back to top
    Copyright © 2024 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)