Search Unity

EntityArchetypeQuery with MonoBehaviours

Discussion in 'Entity Component System' started by JooleanLogic, Jan 16, 2019.

  1. JooleanLogic

    JooleanLogic

    Joined:
    Mar 1, 2018
    Posts:
    447
    Is EntityArchetypeQuery meant to work with MonoBehaviours or is it pure ecs only?
    Code (CSharp):
    1. ComponentType[] components = new ComponentType[]
    2.                 {typeof(Transform), typeof(MyComponentData)};
    3.  
    4. // This works
    5. group = GetComponentGroup(components);
    6.  
    7. // This doesn't
    8. group = GetComponentGroup(new EntityArchetypeQuery{All = components});
    It fails on the call to both GetComponentArray and GetComponentDataArray with
    Following the GetComponentGroup() call, they're both converted internally into ArchetypeQuery and fed into the same CreateEntityGroup function.
    They follow only slightly different paths on their way there and I couldn't see at a glance why the EntityArchetypeQuery path might fail. I don't have access to a debugger.