#Removing Items from linked entity group

1 messages · Page 1 of 1 (latest)

queen pecan
#

We have an entity in the scene. When a player interacts with the entity it spawns a prefab.

In live baking this requires us to create a ton of prefabs which isn't ideal. Instead we want to have the child game object be a prefab instead during runtime, and instantiate that. This would improve the workflow quite a lot

The interactable entity has an LEG, and it includes all the child game objects and instantiates it (when live baking, and only if the gameobject is clicked/inspected in the inspector)

I have a post baking system to filter out those entities from the LEG. Code will be written below.

And simply removing the entity from the LEG doesn't work.
When I destroy the referenced entities using ECB, it destroys it, so i lose all references to the action manager.

#
    [UpdateInGroup(typeof(PostBakingSystemGroup), OrderLast = true)]
    public partial struct FilterActionManagerInlinePrefab : ISystem
    {
        
        public void OnUpdate(ref SystemState state)
        {

            var tempActionManagerLookup = SystemAPI.GetComponentLookup<TempActionManagerPrefabFilterTag>();
                
            var tempActionLookup = SystemAPI.GetComponentLookup<TempActionBakingFilterTag>();

            foreach (var (interactable, linkedEntityGroups, entity) in 
                     SystemAPI
                         .Query<RefRW<Interactable>, DynamicBuffer<LinkedEntityGroup>>()
                         .WithOptions(
                             EntityQueryOptions.IncludePrefab 
                             | EntityQueryOptions.IncludeDisabledEntities
                             | EntityQueryOptions.IgnoreComponentEnabledState)
                         .WithEntityAccess())
            {
                for (int i = linkedEntityGroups.Length -1; i > -1; i--)
                {
                    if (tempActionManagerLookup.HasComponent(linkedEntityGroups[i].Value) ||
                        tempActionLookup.HasComponent(linkedEntityGroups[i].Value))
                    {
                        linkedEntityGroups.RemoveAt(i);
                    }
                }
            }
        }
    }
terse gulch
#

instead of destroying the entity why not just mark it has baking only entity

#

and it'd never be added to the LEG or end up in the world

queen pecan
#

marking as baking only entity defeats the point because then it doesn't end up as a prefab that i can instantiate in runtime

terse gulch
#

ecb.DestroyEntity(linkedEntityGroups[i].Value);
i'm confused, you've destroyed the entity anyway

#

it won't end up the world anyway

#

all BakingOnlyEntity does it call DestroyEntity

#

and stops it being put into the LEG in the first place

queen pecan
#

that can be confusing, let me adjust/edit it

terse gulch
#

basically everything i the subscene that isn't marked as BakingOnlyEntity has to exist for live baking

queen pecan
#

if i mark a prefab as baking only entity, and my interactable has a reference to it. Will that reference remain in runtime?

#

I tried this in a toy project, and it just doesn't end up in the main world

terse gulch
#

no

queen pecan
#

yeah that won't work then

queen pecan
#

is there some other editor time system that overrides it

terse gulch
#

i'm pretty sure it does remove it

#

but then it gets added back, the baking systems run again

#

and your TempActionBakingFilterTag no longer exists

#

is the a BakingType or TemporaryBakingType

#

my guess is you've marked it TemporaryBakingType

queen pecan
#

yeah

terse gulch
#

yeah

#

the baker doesn't run again

#

the baking systems do

#

so it doesn't get removed

queen pecan
#

hmm let me try that

terse gulch
#

change it to BakingTypeAttribute

#

and it /might/ work

queen pecan
#

what would add it again?

#

yeah it looks like it works now

#

🙏 thanks tertle

queen pecan
#
[TemporaryBakingType]: Destroys any components marked with this attribute from the baking output. This means that components marked with this attribute don't remain from one baking pass to the next, and only exist during the time that a particular baker ran.
#

okay makes sense i guess?

terse gulch
#

temp is removed after systems run

#

persistent stay

#

so if you're adding a temp in a baker

#

it wont be added again unless the baker runs again

#

so if the linked entity group baker runs again

#

it will re-add to the LEG