(demo video coming next)
I have a Baking scene, that registers a few prefabs. Only Object on there has this Authoring Component:
namespace Jovian.Authoring
{
public class ShipRegistryAuthoring : MonoBehaviour
{
public GameObject[] ships;
}
public class ShipRegistryBaker : Baker<ShipRegistryAuthoring>
{
public override void Bake(ShipRegistryAuthoring authoring)
{
var self = GetEntity(authoring, TransformUsageFlags.None);
var buffer = AddBuffer<ShipPrefabRegistryElement>(self);
foreach (var ship in authoring.ships)
{
RegisterPrefabForBaking(ship);
var prefab = GetEntity(ship, TransformUsageFlags.None);
buffer.Add(new ShipPrefabRegistryElement {prefab = prefab});
}
}
}
[Serializable]
public struct ShipPrefabRegistryElement : IBufferElementData
{
public Entity prefab;
}
}
It works well when the scene is closed, but if the subscene is open, the objects disappear and the ShipRegistry object doesn't work (I think its buff is empty, but also all entities that were spawned from the prefabs previously in it at runtime disappear)