Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

IJobProcessComponentData with ReadOnly parameters.

Discussion in 'Entity Component System' started by hellowill89, Jun 15, 2018.

  1. hellowill89

    hellowill89

    Joined:
    Jan 8, 2013
    Posts:
    45
    Let's say I have a Job which looks like:

    Code (CSharp):
    1. IJobProcessComponentData<Position>
    Is there a way to mark the Position as ReadOnly so that I can then run two jobs which rely on Position in parallel?
     
  2. isbdnt

    isbdnt

    Joined:
    May 16, 2017
    Posts:
    35
    Code (CSharp):
    1. struct TestJob : IJobProcessComponentData<Position>
    2.         {
    3.             public void Execute([ReadOnly]ref Position data)
    4.             {
    5.  
    6.             }
    7.         }
     
  3. hellowill89

    hellowill89

    Joined:
    Jan 8, 2013
    Posts:
    45
    If done like that, will it allow the two jobs to run in parallel without calling Complete() on the first one?
     
  4. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    Assuming both are only reading Position (they could write to any other 2 orthogonal data sets), you should be able to Schedule them in parallel.