November 2019
Intermediate to advanced
404 pages
12h 9m
English
In essence, a job is just a function running on a separate thread:
using Unity.Collections; using Unity.Jobs; using UnityEngine; public struct SimpleJob : IJob { // Put here a bunch of data... public float number; public NativeArray<float> data; // Write your Execute() function. public void Execute() { data[0] += number; } }
Every job is a struct extending the IJobinterface interface. The struct contains any data we want for the job to use and a function named Execute for the operation we want to execute in the job. The previous example, for instance, just adds a certain number to the first element of an array.
Because, as we said before, multithreading is a very tricky business, Unity offers some limitations in terms of the ...
Read now
Unlock full access