Created
February 15, 2020 04:06
-
-
Save sarkahn/13a283a190bffaa390e93fe2ff4c407d to your computer and use it in GitHub Desktop.
AsDeferredJobArray example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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