#inconsistency in creating Entities in Baking between Open and Closed Subscenes.

1 messages · Page 1 of 1 (latest)

fluid mirage
#

I am creating entities inside a BakingSystem without "attaching" them to a GameObject by adding a SceneSection component to them like this:

[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
    public partial class SystemSettingsBakingSys : SystemBase
    {
        private EntityQuery aiQuery;
        private EntityQuery settingsQuery;

        protected override void OnCreate()
        {
            aiQuery = new EntityQueryBuilder(WorldUpdateAllocator)
                .WithAll<DecisionRequest>()
                .WithAll<SceneSection>()
                .Build(this);
        }

        protected override void OnUpdate()
        {
            if (!aiQuery.IsEmpty)
            {
                var anyAIEntity = aiQuery.ToEntityArray(WorldUpdateAllocator)[0];
                var anySceneSectionComp = EntityManager.GetSharedComponent<SceneSection>(anyAIEntity);
                var anySceneGUID = anySceneSectionComp.SceneGUID;
                
                var assets = AssetDatabaseUtility.GetAllAssetsOfType<ConsiderationScrObj>();
                for (int i = 0; i < assets.Count; i++)
                {
                    var settingsEntity = this.EntityManager.CreateEntity();
                    EntityManager.AddSharedComponent(settingsEntity,new SceneSection
                    {
                        SceneGUID = anySceneGUID,
                        Section = 0
                    });
                }
            }
        }
    }
#

when the subscene is closed everything works as expected. those entities are created and serialized in the subscene.

#

when the subscene is open the entities dont exist. but the System did run.

#

does the open subscene rely on entities to be attached to gameobjects to keep them alive? why is this behaviour different for closed subscenes.

languid sandal
#

Quick question, is aiQuery empty

#

or did it create entities and they aren't appearing