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

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 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 Likes