Search Unity

Feedback EntityCommandBuffer.AddDynamicComponent

Discussion in 'Entity Component System' started by OndrejP, Nov 18, 2020.

  1. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    304
    I'm writing some generic systems and there are few issues I've encountered.

    I cannot create generic job, without knowing up-front all concrete instantiations (fair point)/
    So I tried using `DynamicComponentTypeHandle` to do some work on generic components.

    I can write component data easily (e.g. by passing NativeArray<byte> into job and copying bytes).
    But I cannot add component with data, because no overload of EntityCommandBuffer supports that.

    Can you please add something like:
    `EntityCommandBuffer.AddComponent(Entity e, ComponentType type, NativeArray<byte> data)`

    And similar overload for ECB.ParallerWriter

    This would help a lot!

    It should be easily doable, because ECB just copies component data into stream anyway, instead of copying from `T` it would copy from `NativeArray<byte>`

    Thanks!