# IJobParallelForTransform

> An interface that allows you to perform the same independent operation for each position, rotation and scale of all the transforms passed into a job.

## Definition

* **Type:** Interface
* **Namespace:** [UnityEngine.Jobs](/engine/6000.5/script-reference/unityengine/jobs.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
[JobProducerType(typeof(IJobParallelForTransformExtensions.TransformParallelForLoopStruct<>))]
public interface IJobParallelForTransform
```

## Remarks

This job type is conceptually similar to [IJobFor](/engine/6000.5/script-reference/unity/jobs/ijobfor.md), but instead of iterating over a range of arbitrary data, it iterates over an array of transform data. Because [Transform](/engine/6000.5/script-reference/unityengine/transform.md) is a managed type and can't be safely manipulated by job code, this job type offers a workaround to that limitation.

Transform data is provided to the job in through [TransformAccessArray](/engine/6000.5/script-reference/unityengine/jobs/transformaccessarray.md), which wraps an array of [Transform](/engine/6000.5/script-reference/unityengine/transform.md) instances in an unmanaged TransformAccess type and allows the underlying data to be safely processed in parallel by worker threads.

This job type has the following options to schedule work:

* [IJobParallelForTransformExtensions.RunReadOnlyByRef](/engine/6000.5/script-reference/unityengine/jobs/ijobparallelfortransformextensions/runreadonlybyref.md) runs the job on the main thread and finishes immediately, with read-only access to the transform data.
* [IJobParallelForTransformExtensions.ScheduleReadOnlyByRef](/engine/6000.5/script-reference/unityengine/jobs/ijobparallelfortransformextensions/schedulereadonlybyref.md) schedules the job to run asynchronously, distributing the work across multiple worker threads. This scheduling option can give the best performance, but race conditions can occur if the job writes to shared or global data without proper synchronization.
* [IJobForExtensions.ScheduleByRef](/engine/6000.5/script-reference/unity/jobs/ijobforextensions/schedulebyref.md) is the same as above, but the job has read/write access to the transform data.

`Execute(int index, TransformAccess transform)` is executed once for each index from 0 to the provided length, with the corresponding transform data available through the provided parameter.

`RunReadOnlyByRef` guarantees that the the job's `Execute(int index, TransformAccess transform)` method is invoked sequentially. `ScheduleReadOnlyByRef` and `ScheduleByRef` don't invoke the job's `Execute` method sequentially because it's called from multiple worker threads in parallel to each other.

Each iteration must be independent from other iterations and the safety system enforces this rule for you. The indices have no guaranteed order and are executed on multiple cores in parallel.

For jobs that request read/write access to transform data, Unity automatically splits and sorts the provided transform data into chunks that can be safely processed in parallel. All transforms from the same transform hierarchy will be processed by a single worker thread, to ensure that writing world-space transform data doesn't cause a race condition. However, the order in which transforms within a hierarchy are processed is not guaranteed.

You can use the returned `JobHandle` to check that the job has completed, or pass it to other jobs as a dependency. When you pass a `JobHandle` as a dependency, it ensures that the jobs are executed one after another on the worker threads.

Additional Resources: [IJobParallelForTransformExtensions](/engine/6000.5/script-reference/unityengine/jobs/ijobparallelfortransformextensions.md).

## Examples

```csharp
{code Tests/EditModeAndPlayModeTests/Jobs/Assets/DocumentationExamples/TransformJobDocExamples.cs#ijobparallelfortransform-apidocs-example}
```

## Methods

| Method                                                                                          | Description                                                     |
| ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [Execute](/engine/6000.5/script-reference/unityengine/jobs/ijobparallelfortransform/execute.md) | Performs work against a specific iteration index and transform. |
