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

Recommended way of getting a single result out of a job?

Discussion in 'Entity Component System' started by 5argon, May 14, 2018.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I have went through all the C# Jobs cook book, ECS samples, and ECS classic/hybrid/pure. One thing I am wondering is that when making a job without ECS, how should I get the result of running a job out as a simple value? An example of this kind of job is finding the next prime of an input prime number.

    Currently what I see :
    - Using TransformAccess - Only if the output of computation is a transform
    - Using NativeArray<T> allocated at managed side - Memory is connected so we could read it after .Complete but for multiple values.
    - ECS ComponentSystem : Save computation output values via ComponentDataArray/Inject
    - ECS JobComponentSystem : Same but a job is modifying the data
    - IJobProcessComponentData : Modify component data directly.

    Currently I allocate many NativeArray of size 1 named like "output" and give it to the job and prepare to read it back, then dispose it. But it does not seems like the correct way seeing that it is an "Array".

    As a side question why `bool` prints "not blittable" error when put in `IComonentData` while `bool1` is usable? Also is there any way of putting a string inside `IComponentData` maybe as a fixed size character array? Or I must use series of int to represent each character?
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683