How to create Entity from GameObject in JobComponentSystem?

hi,
I would like to create an Entity from my Game Object in Job Component System. Is any chance to do it in this way? can I create a custom action and add it to EntityCommandBuffer?

public class AddElementToMapSystem : JobComponentSystem
    {
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {   
            EntityCommandBuffer ecb = new EntityCommandBuffer(Allocator.TempJob);
                       
                        Entities
                            .WithoutBurst()
                            .ForEach((ref Entity entity, in ObjectData mapObjectData) =>
                            {
                               GameObject viewHandler =  PoolManager.instance.GetViewHandlerFromPool("objectId");  
                               viewHandler.gameObject.SetActive(true);
                                   
                                GameObjectEntity.AddToEntity(EntityManager, viewHandler.value);                       
                            }
                           
                            ecb.RemoveComponent<ObjectData>(entity);
                           
                        }).Run();
                       
                        ecb.Playback(ApplicationManager.instance.EntityManager);
                        ecb.Dispose();
                       
                       
                        return default;
        }
    }
1 Like

or maybe should I prepare GameObjectConversionSettings before the loop?