Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


RunReadOnlyByRef<T>(ref T, TransformAccessArray)

Runs an IJobParallelForTransform job immediately on the main thread, with read-only access to the transform data.
Read time 1 minuteLast updated 19 days ago

Definition

RunReadOnlyByRef<T>(T, TransformAccessArray)

public static void RunReadOnlyByRef<T>(this ref T jobData, TransformAccessArray transforms) where T : struct, IJobParallelForTransform

Parameters

jobData

T
The job to run.

The TransformAccessArray to run this job on.

Remarks

While this method is useful in development or test environments, it is typically a mistake to use it in production; it offers no real benefits over implementing the job code as a simple main-thread function call. To schedule a job to run asynchronously, use IJobParallelForTransformExtensions.ScheduleReadOnlyByRef.
This method assumes the job only requires read-only access to the transform data, and skips any sorting or filtering of the input transforms which would otherwise be necessary for safety purposes. One important consequence is that any null, deleted, or invalid Transforms in the input TransformAccessArray will not be filtered out, and are still passed to worker threads for processing. Jobs that use this scheduling mode should therefore use TransformAccess.isValid to check whether a specific transform instance is valid before processing its data.
This variant passes the job struct by reference instead of by value, which can be faster than IJobParallelForTransformExtensions.RunReadOnly for larger job structs. Note that worker threads always operate on a local copy of the job struct.