I am having a weird issue and I think it ultimately comes down to not really understanding concurrent command buffers and entities / entity versions.
In my system I have a job which gets entities and does the following commands on them:
public struct FinaliseRoad : IJobForEachWithEntity<RoadCurrentlyBuilding, RoadDisplay>
{
[ReadOnly] public EntityCommandBuffer.Concurrent CommandBuffer;
public void Execute(Entity entity, int index, [ReadOnly] ref RoadCurrentlyBuilding c0, ref RoadDisplay r)
{
CommandBuffer.RemoveComponent<RoadCurrentlyBuilding>(index, entity);
RoadDisplay tempR = r;
r.placing = 0;
CommandBuffer.SetComponent(index, entity, tempR);
}
}
When this code runs, I can see that the entities have had “RoadCurrentlyBuilding” removed but “r.placing” is still showing up as 1 (what the entities are initialised with). I don’t believe that there is anywhere else in my project that modifies the “RoadDisplay” component. The code above successfully removes component data (even if there are multiple components to remove) but doesn’t seem to be able to set the “RoadDisplay” component data.
Any ideas why this is happening?