Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

EntityCommandBufferSystem.AddJobHandleForProducer

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void AddJobHandleForProducer(JobHandle producerJob);

Parameters

Parameter Description
producerJob The JobHandle of a Job which this buffer system should wait for before playing back its pending command buffers.

Description

Adds the specified JobHandle to this system's list of dependencies.

When you write to an EntityCommandBuffer that you created with EntityCommandBufferSystem.CreateCommandBuffer from a job, you must add the JobHandle of that job to this EntityCommandBufferSystem input dependencies by calling this function. Otherwise, this system could attempt to execute the command buffer contents while the writing job is still running, causing a race condition.

Don't call this function for command buffers that you created through the buffer system's Singleton component. Those command buffers are tracked through the singleton component itself, and this system completes all jobs scheduled against that component before it plays the command buffers back.

The following example illustrates how to use one of the default <see cref="Unity.Entities.EntityCommandBufferSystem" />s. The code selects all entities that have one custom component, in this case, AsyncProcessInfo, and processes each entity in the Execute() function of an <see cref="Unity.Entities.IJobEntity" /> Job. After processing, the Job uses a <see cref="Unity.Entities.EntityCommandBuffer" /> to remove the ProcessInfo component and add a ProcessCompleteTag component. Another system could use the ProcessCompleteTag to find entities that represent the end results of the process.