将多个依赖项组合成一个依赖项。
所有用于 IJob 或 IJobParallelFor 作业类型的作业调度方法都采用单个依赖项。有时您可能需要对多个正在运行的作业同时表达依赖关系。使用此方法将一组依赖关系组合成一个可以传递给作业的单个依赖关系。
// Schedule 3 jobs, jobs a and b can run in parallel to each other, // job c will only run once both jobA and jobB has completed
// Schedule job a var jobA = new MyJob(...); var jobAHandle = jobA.Schedule();
// Schedule job b var jobB = new MyJob(...); var jobBHandle = jobB.Schedule();
// For job c, combine dependencies of job a and b // Then use that for scheduling the next job var jobC = new DependentJob(...); var dependency = JobHandle.CombineDependencies(jobAHandle, jobBHandle); jobC.Schedule(dependency);