Skip to content

Instantly share code, notes, and snippets.

@sarkahn
Created February 15, 2020 04:06
Show Gist options
  • Select an option

  • Save sarkahn/13a283a190bffaa390e93fe2ff4c407d to your computer and use it in GitHub Desktop.

Select an option

Save sarkahn/13a283a190bffaa390e93fe2ff4c407d to your computer and use it in GitHub Desktop.
AsDeferredJobArray example
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
var ints = new NativeList<int>(Allocator.TempJob);
inputDeps = new IntJob
{
ints = ints
}.Schedule(inputDeps);
inputDeps = new Reader
{
deferredList = ints.AsDeferredJobArray()
}.Schedule(ints, 32);
return inputDeps;
}
struct IntJob : IJob
{
public NativeList<int> ints;
public void Execute()
{
for (int i = 0; i < 500; ++i)
ints.Add(i);
}
}
struct Reader : IJobParallelForDefer
{
public NativeArray<int> deferredList;
public void Execute(int index)
{
int val = deferredList[index];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment