Search Unity

Adding DynamicBuffers without EntityManager

Discussion in 'Entity Component System' started by DK_A5B, Mar 26, 2019.

  1. DK_A5B

    DK_A5B

    Joined:
    Jan 21, 2016
    Posts:
    110
    Is there any way to add a DynamicBuffer besides using the EntityManager.AddBuffer() method? This is the only way mentioned in the documentation. It appears that the AddBuffer() method for EntityCommandBuffer has been deprecated. The GetBufferFromEntity() method on JobComponentSystem provides a mechanism for accessing an existing buffer, but there's no corresponding “AddBufferToEntity()” method for creating a new one.

    If EntityManager.AddBuffer() is the only way to add DynamicBuffers, then this means that they can only be created on the main thread and there’s no way to create them from within ForEach () or from within a Job. This would make them much more restrictive than Components. Is this the case, or is there something that I'm missing?
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    EntityCommandBuffer.AddBuffer can still be used. You simply have to give it an Entity now.
     
  3. DK_A5B

    DK_A5B

    Joined:
    Jan 21, 2016
    Posts:
    110
    Thanks! I feel rather silly now. I think what threw me was that AddBuffer () shows up as [deprecated] in the autocomplete in Visual Studio:



    But if I actually write out the full method name, it no longer appears to be deprecated:



    So I can see now that it's the non-generic version of the method that was deprecated, and the generic version is still available. I'll have to be more careful.