Search Unity

API 0.4.0 Passing EntityQuery to Job

Discussion in 'Entity Component System' started by RoughSpaghetti3211, Jan 12, 2020.

  1. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Quick question, Can I no longer pass EntityQuery to job Schedule ?

    Code (CSharp):
    1.  
    2.  
    3. inputDeps = Entities.ForEach((ref EntityDataComponent c) => { c.EntityData = 11; }).Schedule( qEntityData, inputDeps);
    4.  
    5.  
     
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    That just returns the entity query generated by the lambda expression, does not let you pass it in.

    As of 0.4, you can not pass an entity query into a jobcomponentsystem lambda job. I believe I remember they said this is just a missing feature and will be added at some point.
     
  4. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    What should we be moving to the new API , for example how can I possible move this to the new lambda job

    Code (CSharp):
    1.  
    2.  
    3. private struct SetTiles : IJobForEach_B<TilesBufferComponent>
    4. {
    5.     public EntityCommandBuffer.Concurrent Ecb;
    6.     [DeallocateOnJobCompletion] public NativeArray<Entity> ETiles;
    7.  
    8.     public void Execute([ReadOnly] DynamicBuffer<TilesBufferComponent> b)
    9.     {
    10.         for (var i = 0; i < b.Length; i++)
    11.         {
    12.             var e = ETiles[i];
    13.             Ecb.SetComponent(i, e, new TilePositionComponents
    14.             {
    15.                 Position = new float3(b[i].PositionX,
    16.                     b[i].PositionY,
    17.                     b[i].PositionZ)
    18.             });
    19.         }
    20.     }
    21. }
    22.