I instantiated an entity using this entity command buffer line(in an IJobEntity) ECB.Instantiate(entityToSpawn);, and I can see the entity in the scene, but on the runtime inspector, my reference to the instantiated entity shows up as Invalid (Entity {-1:-22}). And when I try to destroy the same entity, I get this error thrown in the inspector:
ArgumentException: System.InvalidOperationException: Deferred Entity Unity.Entities.Entity was created by a different command buffer. Deferred Entities can only be used by the command buffer that created them.
This Exception was thrown from a function compiled with Burst, which has limited exception support.
And the entity isn't destroyed. What could've gone wrong?