I have an entities with 2 components VertexComponent and TileComponent. In my IJobParallelFor i copy some data from VertexComponent to TileComponent. After the copy is done I want to remove VertexComponent from this entity. I was wondering I can do this in a single IJobParallelFor job. How I attempted it below errors with an
IndexOutOfRangeException: Index 0 is out of range of ‘0’ Length. on Entity e = eVertexBuffer*; So clearly I need so sort of post command for remove. Any ideas. Thanks in advance*
```csharp
-
[RequireComponentTag(typeof(VertexComponent))] struct BuildVertexEntitiesJob : IJobParallelFor { [ReadOnly] public EntityCommandBuffer.Concurrent ecb; [DeallocateOnJobCompletion] [ReadOnly] public NativeArray<Entity> eVertexBuffer; [ReadOnly] public ComponentDataFromEntity<VertexComponent> vertexEntity; public void Execute(int i) { Entity e = eVertexBuffer[i]; var vertexData = vertexEntity[e]; ecb.SetComponent<TileComponent>(i, e, new TileComponent { position = new float3(vertexData.positionX, vertexData.positionY, vertexData.positionZ), connectedTriA = Entity.Null, connectedTriB = Entity.Null, connectedTriC = Entity.Null, connectedTriD = Entity.Null, connectedTriE = Entity.Null, connectedTriF = Entity.Null }); ecb.RemoveComponent<VertexComponent>(i, e); } } protected override JobHandle OnUpdate(JobHandle inputDeps) { var hexSphereBuildComponent = GetSingletonEntity<HexSphereBuildDataComponent>(); _hexSphereBuildDataSingleton = EntityManager.GetComponentData<HexSphereBuildDataComponent>(hexSphereBuildComponent); // // Job BuildVertexEntitiesJob jhBuildVertexEntities = new BuildVertexEntitiesJob() { ecb = ecbs.CreateCommandBuffer().ToConcurrent(), eVertexBuffer = eqVertexComp.ToEntityArray(Allocator.TempJob), vertexEntity = GetComponentDataFromEntity<VertexComponent>(true) }; inputDeps = jhBuildVertexEntities.Schedule(_hexSphereBuildDataSingleton.vertexCount, 12, inputDeps); ecbs.AddJobHandleForProducer(inputDeps); inputDeps.Complete(); return inputDeps; }*
```