Method MoveComponent
MoveComponent<T>(EntityManager, Entity, Entity)
Safely move a managed 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. This entity must have a component
of type |
Entity | dst | The Entity the managed component will be added to. If this entity already has
|
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.