SetBatchTransform
Set the transform for a batch of PhysicsBody using a span of PhysicsBody.BatchTransform. If invalid values are passed to the batch, they will simply be ignored. For best performance, the bodies contained in the batch should all be part of the same PhysicsWorld. If the bodies in the batch are not contained in the same PhysicsWorld, the batch should be sorted by the PhysicsWorld the bodies are contained within.
Read time 2 minutesLast updated 2 days ago
Definition
- Type: Method
- Namespace: Unity.U2D.Physics
- Assembly: UnityEngine.PhysicsCore2DModule
SetBatchTransform(ReadOnlySpan<BatchTransform>)
Set the transform for a batch of PhysicsBody using a span of PhysicsBody.BatchTransform. If invalid values are passed to the batch, they will simply be ignored. For best performance, the bodies contained in the batch should all be part of the same PhysicsWorld. If the bodies in the batch are not contained in the same PhysicsWorld, the batch should be sorted by the PhysicsWorld the bodies are contained within.
public static int SetBatchTransform(ReadOnlySpan<PhysicsBody.BatchTransform> batch)
Parameters
The batch of bodies and values to set.
Returns
Type | Description |
|---|---|
| int | The number of bodies that were ignored (not set because the body was invalid). A single warning is logged when any are ignored. |
SetBatchTransform(ReadOnlySpan<BatchTransform>, bool)
Set the transform for a batch of PhysicsBody using a span of PhysicsBody.BatchTransform, optionally writing each pose to the _transformObject of its body. If invalid values are passed to the batch, they will simply be ignored. When is true, each pose set is also written to the _transformObject of its body, without producing a PhysicsEvents.TransformChangeEvent. Writing poses requires all the valid bodies in the batch to be in the same PhysicsWorld and each to have its own _transformObject assigned, not shared with another body in the batch. Invalid bodies in the batch are still simply ignored. The _transformWriteMode and _transformWriteMode do not control this explicit write, except that PhysicsWorld.TransformWriteMode.Fast2D selects the faster rotation write. Writing poses must be done on the main thread.
writePosespublic static int SetBatchTransform(ReadOnlySpan<PhysicsBody.BatchTransform> batch, bool writePoses)
Parameters
The batch of bodies and values to set.
Whether to also write the poses to the _transformObject of each body in the batch.
Returns
Type | Description |
|---|---|
| int | The number of bodies that were ignored (not set because the body was invalid). A single warning is logged when any are ignored. |