AddJobHandleForProducer(JobHandle)
Adds the specified JobHandle to this system's list of dependencies.
Read time 1 minuteLast updated a day ago
Definition
- Type: Method
- Namespace: Unity.Entities
- Assembly: UnityEngine.EntitiesModule
public void AddJobHandleForProducer(JobHandle producerJob)
Parameters
The JobHandle of a Job which this buffer system should wait for before playing back its pending command buffers.
Remarks
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 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.
SingletonThe following example illustrates how to use one of the default EntityCommandBufferSystems. The code selects all entities that have one custom component, in this case, , and processes each entity in the function of an IJobEntity Job. After processing, the Job uses a EntityCommandBuffer to remove the component and add a component. Another system could use the to find entities that represent the end results of the process.
AsyncProcessInfoExecute()ProcessInfoProcessCompleteTagProcessCompleteTag