Search Unity

  1. Want to see 2020.1b in action? Sign up for our Beta 2020.1 Overview Webinar on April 20th for a live presentation from our evangelists and a Q&A session with guests from R&D.
    Dismiss Notice
  2. Interested in giving us feedback? Join our online research interviews on a broad range of topics and share your insights with us.
    Dismiss Notice
  3. We're hosting a webinar for the new Input System where you'll be able to get in touch with the devs. Sign up now and share your questions with us in preparation for the session on April 15.
    Dismiss Notice

From ComponentSystem to JobComponentSystem

Discussion in 'Data Oriented Technology Stack' started by Enzi, Jan 30, 2020.

  1. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    269
    Hey all!

    I've way too many ComponentSystem and it's time to convert them as advised to a JobComponentSystem but I've stumbled upon some questions and problems.

    Are there any docs specific to this change and improvement?

    My previous systems were all running on EntityQueries. I've not found a direct way to use those queries with the Entities.ForEach syntax. Did I just miss it or is it not possible?

    In one system I need a lookup for positions and get it outside the scope of the ForEach like:
    Code (CSharp):
    1. var translationData = GetComponentDataFromEntity<Translation>(true);
    Usage then ends in an error that translationData should be marked [ReadOnly] and I don't know how to fix that.

    GetComponentDataFromEntity was no issue with struct jobs. How should I solve this? Is there a way?

    Burst related: I found out that one ForEach could not be compiled because it was using a List<Entity> inside. I caught it pretty quickly but I don't think it should be neccesary to go into so much detail to find this out. There was no error in the console and you have to navigate pretty deep in the Burst inspector.
     
  2. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    269
    bump
     
  3. Sarkahn

    Sarkahn

    Joined:
    Jan 9, 2013
    Posts:
    266
    Have you gone over the manual page for it? It's one of the better docs pages I've seen.

    The entity queries for the ForEach is implicit, based on which arguments you give to the lambda. You can even capture the query at compile time if needed, the docs page will tell you more.

    You can pass in the CDFE as read only with Entities.WithReadOnly(translationData).ForEach(...
     
    Enzi likes this.
  4. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    575
    Asked here. That is missing. Don't really know when will it be added.
     
    Enzi likes this.
  5. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    269
    Thanks for the answers! Much appreciated!
     
unityunity