Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How do I add ComponentType.FixedArray with EntityCommandBuffer

Discussion in 'Entity Component System' started by Spy-Shifty, May 5, 2018.

  1. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Hi,

    I want to create an entity with a fixedarray of components.

    Normaly I would do the following:
    Code (CSharp):
    1.  
    2. Entity entity = EntityManager.CreateEntity(networkReceiveMessageArchetype);
    3. EntityManager.AddComponent(entity, ComponentType.FixedArray(typeof(byte), dataBuffer.Length));
    4. NativeArray<byte> messageData = EntityManager.GetFixedArray<byte>(entity);
    5. for (int i = 0; i < dataBuffer.Length; i++) {
    6.      messageData[i] = dataBuffer[i] ;
    7. }
    8.  
    How would I do the same with a EntityCommandBuffer?
     
    Last edited: May 5, 2018
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    May be you must define FixedArray (and initialize) before and put them in to second arg in buf.AddComponent