Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug EntityQueryMask is not working on subscene entities

Discussion in 'Entity Component System' started by quabug, Aug 2, 2020.

  1. quabug

    quabug

    Joined:
    Jul 18, 2015
    Posts:
    66
    ticket: 1267604_lf7a5ohr9r1c2gi9

    1. What happened
    `EntityQueryMask.Matches` on entity of sub scene always return false.

    2. How we can reproduce it using the example you attached
    Running SampleScene and observe there's no logs in console window while only the "SubSceneEntity" is enabled.
    Try to enable `Entity` outside of subscene, and now there's logs show up in console window.
     

    Attached Files:

  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
    I just get this error in console trying to convert your scene.
    What are you trying to do here? I'd be shocked if you could actually store a copy of EntityComponentStore* in a subscene.... (which is what EntityQueryMask holds)
     
  3. quabug

    quabug

    Joined:
    Jul 18, 2015
    Posts:
    66
    I am trying to create a dynamic `EntityQueryMask` and store the mask inside a component data, that I could use to filter entities in system.
    It works fine without subscene. But `QueryMaskArray` of `Archetype` always return a different bits for entity in subscene even the archetype should be the same as the entity outside of subscene.
    upload_2020-8-2_22-4-37.png

    What do you mean by "... EntityComponentStore* in a subscene"? Do you mean "the EntityQueryMask should not be used in subscene because EntityComponentStore cannot be stored in subscene"?

    For console error, which version of unity do you use? I only test this on 2020.1.0f1.
     
  4. quabug

    quabug

    Joined:
    Jul 18, 2015
    Posts:
    66
    Okay, seems I should use `World.DefaultGameObjectInjectionWorld.EntityManager` instead of `dstManager` from SubScene world to create mask.
    Because, as @tertle said, EntityComponentStore* point to different place between two worlds, which eventually get wrong archetype of entity since entity index is not the same in those two worlds.
     
  5. quabug

    quabug

    Joined:
    Jul 18, 2015
    Posts:
    66
    Besides that, the QueryMaskArray is also not set with the right mask between two worlds.
    upload_2020-8-3_0-4-42.png