Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

EntityQueryDesc component types always have readwrite permission

Discussion in 'Entity Component System' started by kleicht, Jul 2, 2019.

  1. kleicht

    kleicht

    Joined:
    Aug 1, 2018
    Posts:
    16
    It seems like even though I specify ComponentTypes as ReadOnly in EntityQueryDesc definition, it still gets converted to ReadWrite permission. (Entities version: preview 33 - 0.0.12 in EntityGroupManager.CalculateRequiredComponentsFromQuery() line: 381 )
    Is that the correct behaviour?

    I would like to use the EntityQueryDesc with a None filter, but using this way all of the components will be marked as changed.
    If I use IJobForEachWithEntity with ExcludeComponent I get the desired behaviour. But in my case I cant use IJobForEachWithEntity for this query.

    Edit: Updated picture to show the workaround to this issue.
     

    Attached Files:

    Last edited: Jul 2, 2019
  2. kleicht

    kleicht

    Joined:
    Aug 1, 2018
    Posts:
    16
    Looks like there is a way to solve this issue.
    I can just use GetEntityQuery with ComponentType[] override and than use the ComponentType.Exclude<T>() version, to skip unwanted components.
    That will use EntityGroupManager.CreateQuery(ref ScratchAllocator scratchAllocator, EntityQueryDesc[] queryDesc) override under the hood, which will correctly set up ReadOnly permissions.
     
  3. threedots1

    threedots1

    Joined:
    Oct 9, 2014
    Posts:
    88
    Yeah I can confirm the same bug.

    Creating an EntityQuery with EntityQueryDesc does not respect ReadOnly restrictions
     
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    Coincidently noticed this yesterday as well. It's not always the case but seems to pop up when getting query from a cache or something.
     
  5. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    760
    Did this ever get fixed in entities 0.50?