Search Unity

How to run system if first query matches, but pick second query entities for processing?

Discussion in 'Entity Component System' started by xVergilx, Jul 25, 2019.

  1. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Title.

    I've got an entity query that should determine, whether the system should run.
    And an entity query I want to run processing on. Thing is, I need to return dependencies for the job that runs on the second query, so I can't just use GetEntityQuery(...) for setting dependencies.

    And I can't leave
    var components = query.ToComponentDataArray<T>(Allocator.TempJob))
    if (components.Length == 0) return;

    because that will eat some ops.

    So, how do I run system on this case?

    Note that components of the first query is located on the different entity, so I can't add them to the second query.
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    RequireForUpdate?
     
    xVergilx likes this.
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Yep, that was exactly what I was looking for. There's even RequireSingletonForUpdate. Really cool stuff.

    Thanks :)