Search Unity

[SOLVED] Help! What is that attribute that only run a system with all its queries?

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

  1. eterlan

    eterlan

    Joined:
    Sep 29, 2018
    Posts:
    177
    I remember there is a new API, as @5argon mentioned at some place, which only allow system to run with all its queries return results.
    I'm not lazy! I try my best to search the packages, documents and forum, with those key words: "update", "attribute", "dis", but nothing found.. Any one know about that?
     
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    You need to set your IComponents to a specific WriteGroup then in your query you filter it with Options = EntityQueryOptions.FilterWriteGroup
    Also have a closer look at the Transform System because it use it.
     
    eterlan likes this.
  3. eterlan

    eterlan

    Joined:
    Sep 29, 2018
    Posts:
    177
    Thanks for your help! I think WriterGroup is to exclude those component without explicitly declared in query. What I'm trying is to make system only run with queryA AND queryB, not OR.
     
    GilCat likes this.
  4. eterlan

    eterlan

    Joined:
    Sep 29, 2018
    Posts:
    177
    Thanks @GilCat , I found it! It is under the ComponentSystemBase with comments!

    public void RequireForUpdate(EntityQuery query)
     
    5argon likes this.
  5. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Note that this will override all prior update criteria behaviour as well. For example previously you have 2 EQs working on a system with GetEntityQuery, so if one of the 2 EQs got a query then it is an Update. But if you use RequireForUpdate once with a new 3rd EQ then the prior 2 EQs doesn't matter anymore. It is either you got a query in that 3rd EQ and get an update, or no update.
     
    psuong and eterlan like this.
  6. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    Yeah, right :) I was on the phone and replied too quickly :p
    I believe you can combine all your EntityQueryDesc and make that combined query a requirement:
    Code (CSharp):
    1.       var combineQuery = GetEntityQuery(queryDesc1, queryDesc2, queryDesc3);
    2.       RequireForUpdate(combineQuery);
    Haven't tested it tho.
     
    psuong and eterlan like this.