The relevant code is essentially this:
EDIT:
var commandBuffer = new EntityCommandBuffer(Allocator.TempJob);
var query = GetEntityQuery(typeof(OtherComponent));
otherEntity = query.GetSingletonEntity(); // otherEntity is assigned as expected, and it's components are used in the job without issue
Entities
.WithoutBurst()
.WithAll<TypeToIterateOn>()
.ForEach((Entity entity, ref Translation translation, ref TypeToIterateOn x) =>
{
var newEntity = commandBuffer.Instantiate(prefab);
commandBuffer.SetComponent(newEntity, translation); // Works
var newComponent = new NewComponentType
{
Source = entity, // Works fine
Target = otherEntity // This causes the new entity not to instantiate
};
commandBuffer.AddComponent(newEntity, newComponent);
}).Run();
commandBuffer.Playback(EntityManager);
commandBuffer.Dispose();
I’m trying to Instantiate an entity from a prefab, and add a new component with the data I set.
Instantiating works fine, I can set the data on Translation component, I can add the component, but as soon as I try to set the data the entity completely fails to instantiate. There is no error or exception.
It works with all the data in the component, but not if I set the entity I got via the query earlier (which exists).