Subscenes with entity prefab references does not properly run baking systems for those references. Adding prefab in subscene manually makes it run the system.
Simple test code.
Code
public struct PrefabTestData : IComponentData
{
public Entity prefabEntity;
}
public class PrefabAuthoring : MonoBehaviour
{
public GameObject prefab;
public class Baker : Baker<PrefabAuthoring>
{
public override void Bake(PrefabAuthoring authoring)
{
AddComponent(new PrefabTestData()
{
prefabEntity = GetEntity(authoring.prefab)
});
}
}
}
// ...
public struct DummyData : IComponentData
{
public int debugValue;
}
public class DummyAuthoring : MonoBehaviour
{
public class Baker : Baker<DummyAuthoring>
{
public override void Bake(DummyAuthoring authoring)
{
AddComponent(new DummyData()
{
debugValue = 0
});
}
}
}
// ...
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
public partial class DummyBakingSystem : BakingSystem
{
protected override void OnUpdate()
{
foreach (var dummyData in SystemAPI.Query<RefRW<DummyData>>())
{
dummyData.ValueRW.debugValue = 666;
}
}
}
// ...
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)]
public partial class SpawnSystem : SystemBase
{
protected override void OnUpdate()
{
var ecb = SystemAPI.GetSingleton<BeginSimulationEntityCommandBufferSystem.Singleton>().CreateCommandBuffer(World.Unmanaged);
foreach (var (prefabData, entity) in SystemAPI.Query<RefRO<PrefabTestData>>().WithEntityAccess())
{
ecb.Instantiate(prefabData.ValueRO.prefabEntity);
ecb.DestroyEntity(entity);
}
}
}
CASE IN-27666