This was going to be a post about why EntityManager.Instantiate returns Entity.Null when trying to instantiate prefabs in standalone build but after some more debugging I realized it only returns null for prefabs I tried to create in the baker on my own.
The code I was using in the baker:
Entity containerPrefab = baker.CreateAdditionalEntity(TransformUsageFlags.None, false, _Name + "ContainerItem");
baker.AddComponent<ContainerItemTag>(containerPrefab);
baker.AddComponent<Prefab>(containerPrefab);
baker.AddBuffer<LinkedEntityGroup>(containerPrefab);
baker.AddComponent(containerPrefab, new ItemDataComponent
{
Icon = _Icon,
ItemSize = _ContainerSize
});
baker.AddComponent<ContainerPosition>(containerPrefab);
Calling EntityManager.Instantiate on the prefab works fine in editor but fails by silently returning Entity.Null in a build. If I remove the Prefab and LinkedEntityGroup components before calling instantiate it works again.
I'm suspecting we are not supposed to create our own custom prefab entities? Or am I missing something? My end goal is to have a prefab like entity I can spawn on demand which holds certain properties (in this case a weak reference to a sprite, size in the inventory etc.).