Version: 2020.1

JobHandle.CombineDependencies

切换到手册
public static Unity.Jobs.JobHandle CombineDependencies (Unity.Jobs.JobHandle job0, Unity.Jobs.JobHandle job1);
public static Unity.Jobs.JobHandle CombineDependencies (Unity.Jobs.JobHandle job0, Unity.Jobs.JobHandle job1, Unity.Jobs.JobHandle job2);
public static Unity.Jobs.JobHandle CombineDependencies (NativeArray<JobHandle> jobs);
public static Unity.Jobs.JobHandle CombineDependencies (NativeSlice<JobHandle> jobs);

描述

将多个依赖关系合并为一个。

所有作业安排函数(例如 IJobIJobParallelFor)都有一个依赖关系,有时需要同时针对多个正在运行的作业指明依赖关系。因此,您可以使用该函数将一组依赖关系合并为可传递给作业的单个依赖关系。

// Schedule 3 jobs, job a and be 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);