"Unknown Type: All ComponentType must be known" in 0.17.0

So I’m trying to remove a dynamic buffer component off an entity like so:

 public class LaneInitialization : SystemBase
    {
        private EndInitializationEntityCommandBufferSystem _endInitializationEcbSystem;

        protected override void OnCreate()
        {
            _endInitializationEcbSystem = World.GetOrCreateSystem<EndInitializationEntityCommandBufferSystem>();
        }

        private void OnUpdate()
        {
            var ecb = _endInitializationEcbSystem.CreateCommandBuffer().AsParallelWriter();

            Entities
                .WithBurst()
                .ForEach(
                    (Entity entity, int entityInQueryIndex)
                        =>
                    {
                           //...
                        ecb.RemoveComponent<DynamicBuffer<EntryNode>>(entityInQueryIndex, entity);
                        ecb.RemoveComponent<DynamicBuffer<OnStreetNode>>(entityInQueryIndex, entity);
                        ecb.RemoveComponent<DynamicBuffer<ExitNode>>(entityInQueryIndex, entity);
                    }).ScheduleParallel();

But I get an error saying:
Unknown Type:`Unity.Entities.DynamicBuffer`1[Components.EntryNode]` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].
I’ve searched the forum and documentation and tried to register the type in an AssemblyInfo.cs like so:

[assembly: RegisterGenericComponentType(typeof(DynamicBuffer<EntryNode>))]

But the error persists. Am I not reading the error correctly? For reference, this is my EntryNode

public struct EntryNode : IBufferElementData
    {
        public static implicit operator Translation(EntryNode e) { return e.Value; }

        public static implicit operator EntryNode(Translation e) { return new EntryNode { Value = e }; }
       
        public Translation Value;
    }

Try :

ecb.RemoveComponent(entityInQueryIndex, entity);
instead of
ecb.RemoveComponent<DynamicBuffer>(entityInQueryIndex, entity);

Worked like a charm Thanks!

I do have a general follow-up question.

If I were to create an Entities.Foreach() and would want to read data from the whole DynamicBuffer<EntryNode> would I use in EntryNode or rather in DynamicBuffer<EntryNode>
In case of the first, how would I access the other EntryNodes in the buffer?

Entities.ForEach((DynamicBuffer node)=>{});

I believe.

1 Like

Thanks very much. I’ll close this thread then