Search Unity

Can I somehow access an EntityQueryBuilder from a JobComponentSystem?

Discussion in 'Entity Component System' started by diesoftgames, Apr 5, 2019.

  1. diesoftgames

    diesoftgames

    Joined:
    Nov 27, 2018
    Posts:
    122
    Using a ComponentSystem, I can get a class in lieu of a component in Entities.ForEach to get legacy components on my converted entities (I've done this to access Animators for instance). How can I do the same in a JobComponentSystem which doesn't have an EntityQueryBuilder "Entities" property to use for this? To be clear, I'm not looking to get references in a job, I'm happy to use the main thread OnUpdate, I just also want to run jobs in this system (just to add some components to entities). So is there some way I can get access to an EntityQueryBuilder in a JobComponentSystem?

    EDIT: I forgot to mention, I was trying to use an EntityArchetypeQuery, but then I'm unsure how to get the behaviour from the Entity. eg:

    Code (CSharp):
    1.  new EntityArchetypeQuery {
    2.     All = new ComponentType[] { typeof(Tilemap) },
    3.     None = Array.Empty<ComponentType>(),
    4.     Any = Array.Empty<ComponentType>()});
     
    Last edited: Apr 5, 2019
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    I don't think you can do that.
    Best solution is to have two systems. One JobComponentSystem for the jobs and another ComponentSystem for the rest.
     
  3. diesoftgames

    diesoftgames

    Joined:
    Nov 27, 2018
    Posts:
    122
    Hmmm, well the tagging will be dependent on the reference/array data that is being used in this system, so I can't really break it up into systems, so I guess I'll just have to add the components without using a Job system. Not ideal but it'll get the job done.