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

EntityQuery negative / negated ISharedComponentData Filter

Discussion in 'Entity Component System' started by g3nuine3, Jan 19, 2020.

  1. g3nuine3

    g3nuine3

    Joined:
    Feb 13, 2018
    Posts:
    10
    Is it possible to exclude certain ISharedComponentData values from an EntityQuery?

    I imagine something like this:
    entityQuery.SetFilterExclude(new SharedComponent() { value = 1 });
     
  2. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,554
    I think inversed filter currently could only be done via manual chunk iteration. Or a very involving way of iterating through all currently used SCD values (GetAllUniqueSharedComponentData) and set those one by one except the one you don't want.. Perform work before setting the next one.

    Either solution, first I wish there is an API to directly get/search SCD index from any single SCD value faster than GetAllUniqueSharedComponentData.
     
    Last edited: Jan 19, 2020
    g3nuine3 likes this.
  3. g3nuine3

    g3nuine3

    Joined:
    Feb 13, 2018
    Posts:
    10
    I solved it by using IJobChunk to be able to lookup the SharedComponentData-index of the chunk (seems its not possible for a single entity in a job) and passing the SharedComponentData-indices which I want to exclude to the job.

    This is a lot of code so a future addition of some way of negative filtering would be very welcome.