Hello everyone. In the https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/components-enableable-use.html is said that I can
enable and disable components on jobs running on worker threads without using an entity command buffer or creating a sync point.
But when I tried to do that Unity errored (attention to the screenshot) with the messages, says that in the job Job.Complete was called. As I understand right it means not the sync point, but just completing the needed dependencies. But still because of that error I cannot not enable/disable components on jobs. So where am I wrong here?
Code for this jobs is:
{
[ReadOnly] public CollisionWorld collisionWorld;
public RaycastInput raycastInput;
public NativeReference<bool> raycastResult;
public void Execute()
{
raycastResult.Value = collisionWorld.CastRay(raycastInput, out RaycastHit raycastHit);
if (raycastResult.Value)
{
World.DefaultGameObjectInjectionWorld.EntityManager.SetComponentEnabled<SelectTag>(raycastHit.Entity, true);
}
}
}
public partial struct DeselectAllUnitsJob : IJobEntity
{
public NativeReference<bool> raycastResult;
public void Execute(in SelectTag selectTag, in Entity entity)
{
if (raycastResult.Value)
World.DefaultGameObjectInjectionWorld.EntityManager.SetComponentEnabled<SelectTag>(entity, false);
}
}```