# SetBatchGeometry

> Set a batch of PhysicsShape to the corresponding CircleGeometry. The two spans must be the same length; shape[i] is set to geometry[i]. Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call PhysicsBody.ApplyMassFromShapes on any affected body if a mass update is required. Invalid shapes or geometry in the batch are ignored. For best performance, the shapes should all be part of the same PhysicsWorld, sorted by world otherwise.

## Definition

* **Type:** Method
* **Namespace:** [Unity.U2D.Physics](/engine/6000.7/script-reference/unity/u2d/physics.md)
* **Assembly:** UnityEngine.PhysicsCore2DModule

## SetBatchGeometry(ReadOnlySpan\<PhysicsShape>, ReadOnlySpan\<CircleGeometry>)

Set a batch of [PhysicsShape](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape.md) to the corresponding [CircleGeometry](/engine/6000.7/script-reference/unity/u2d/physics/circlegeometry.md). The two spans must be the same length; shape\[i] is set to geometry\[i]. Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call [PhysicsBody.ApplyMassFromShapes](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/applymassfromshapes.md) on any affected body if a mass update is required. Invalid shapes or geometry in the batch are ignored. For best performance, the shapes should all be part of the same [PhysicsWorld](/engine/6000.7/script-reference/unity/u2d/physics/physicsworld.md), sorted by world otherwise.

```csharp
public static int SetBatchGeometry(ReadOnlySpan<PhysicsShape> shapes, ReadOnlySpan<CircleGeometry> geometry)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set.**** (\[ReadOnlySpan\<CircleGeometry>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The geometry to set on each corresponding shape.

### Returns

| Type                                                       | Description                                                                     |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of shapes that were ignored (not set because the shape was invalid). |

## SetBatchGeometry(ReadOnlySpan\<PhysicsShape>, ReadOnlySpan\<CapsuleGeometry>)

Set a batch of [PhysicsShape](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape.md) to the corresponding [CapsuleGeometry](/engine/6000.7/script-reference/unity/u2d/physics/capsulegeometry.md). The two spans must be the same length; shape\[i] is set to geometry\[i]. Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call [PhysicsBody.ApplyMassFromShapes](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/applymassfromshapes.md) on any affected body if a mass update is required. Invalid shapes or geometry in the batch are ignored. For best performance, the shapes should all be part of the same [PhysicsWorld](/engine/6000.7/script-reference/unity/u2d/physics/physicsworld.md), sorted by world otherwise.

```csharp
public static int SetBatchGeometry(ReadOnlySpan<PhysicsShape> shapes, ReadOnlySpan<CapsuleGeometry> geometry)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set.**** (\[ReadOnlySpan\<CapsuleGeometry>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The geometry to set on each corresponding shape.

### Returns

| Type                                                       | Description                                                                     |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of shapes that were ignored (not set because the shape was invalid). |

## SetBatchGeometry(ReadOnlySpan\<PhysicsShape>, ReadOnlySpan\<PolygonGeometry>)

Set a batch of [PhysicsShape](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape.md) to the corresponding [PolygonGeometry](/engine/6000.7/script-reference/unity/u2d/physics/polygongeometry.md). The two spans must be the same length; shape\[i] is set to geometry\[i]. Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call [PhysicsBody.ApplyMassFromShapes](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/applymassfromshapes.md) on any affected body if a mass update is required. Invalid shapes or geometry in the batch are ignored. For best performance, the shapes should all be part of the same [PhysicsWorld](/engine/6000.7/script-reference/unity/u2d/physics/physicsworld.md), sorted by world otherwise.

```csharp
public static int SetBatchGeometry(ReadOnlySpan<PhysicsShape> shapes, ReadOnlySpan<PolygonGeometry> geometry)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set.**** (\[ReadOnlySpan\<PolygonGeometry>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The geometry to set on each corresponding shape.

### Returns

| Type                                                       | Description                                                                     |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of shapes that were ignored (not set because the shape was invalid). |

## SetBatchGeometry(ReadOnlySpan\<PhysicsShape>, ReadOnlySpan\<SegmentGeometry>)

Set a batch of [PhysicsShape](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape.md) to the corresponding [SegmentGeometry](/engine/6000.7/script-reference/unity/u2d/physics/segmentgeometry.md). The two spans must be the same length; shape\[i] is set to geometry\[i]. Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call [PhysicsBody.ApplyMassFromShapes](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/applymassfromshapes.md) on any affected body if a mass update is required. Invalid shapes or geometry in the batch are ignored. For best performance, the shapes should all be part of the same [PhysicsWorld](/engine/6000.7/script-reference/unity/u2d/physics/physicsworld.md), sorted by world otherwise.

```csharp
public static int SetBatchGeometry(ReadOnlySpan<PhysicsShape> shapes, ReadOnlySpan<SegmentGeometry> geometry)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set.**** (\[ReadOnlySpan\<SegmentGeometry>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The geometry to set on each corresponding shape.

### Returns

| Type                                                       | Description                                                                     |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of shapes that were ignored (not set because the shape was invalid). |

## SetBatchGeometry(ReadOnlySpan\<PhysicsShape>, ReadOnlySpan\<ChainSegmentGeometry>)

Set a batch of [PhysicsShape](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape.md) to the corresponding [ChainSegmentGeometry](/engine/6000.7/script-reference/unity/u2d/physics/chainsegmentgeometry.md). The two spans must be the same length; shape\[i] is set to geometry\[i]. If a shape is already a chain segment, its owning chain is preserved. Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call [PhysicsBody.ApplyMassFromShapes](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/applymassfromshapes.md) on any affected body if a mass update is required. Invalid shapes or geometry in the batch are ignored. For best performance, the shapes should all be part of the same [PhysicsWorld](/engine/6000.7/script-reference/unity/u2d/physics/physicsworld.md), sorted by world otherwise.

```csharp
public static int SetBatchGeometry(ReadOnlySpan<PhysicsShape> shapes, ReadOnlySpan<ChainSegmentGeometry> geometry)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set.**** (\[ReadOnlySpan\<ChainSegmentGeometry>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The geometry to set on each corresponding shape.

### Returns

| Type                                                       | Description                                                                     |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of shapes that were ignored (not set because the shape was invalid). |

## SetBatchGeometry(ReadOnlySpan\<PhysicsShape>, CircleGeometry)

Set a batch of [PhysicsShape](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape.md) all to the same [CircleGeometry](/engine/6000.7/script-reference/unity/u2d/physics/circlegeometry.md). Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call [PhysicsBody.ApplyMassFromShapes](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/applymassfromshapes.md) on any affected body if a mass update is required. Invalid shapes in the batch are ignored. For best performance, the shapes should all be part of the same [PhysicsWorld](/engine/6000.7/script-reference/unity/u2d/physics/physicsworld.md), sorted by world otherwise.

```csharp
public static int SetBatchGeometry(ReadOnlySpan<PhysicsShape> shapes, CircleGeometry geometry)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set.**** (\[CircleGeometry]\(/engine/6000.7/script-reference/unity/u2d/physics/circlegeometry)): The geometry to set on every shape.

### Returns

| Type                                                       | Description                                                                                                                    |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of shapes that were ignored (not set because the shape was invalid). If the geometry is invalid, no shapes are set. |

## SetBatchGeometry(ReadOnlySpan\<PhysicsShape>, CapsuleGeometry)

Set a batch of [PhysicsShape](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape.md) all to the same [CapsuleGeometry](/engine/6000.7/script-reference/unity/u2d/physics/capsulegeometry.md). Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call [PhysicsBody.ApplyMassFromShapes](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/applymassfromshapes.md) on any affected body if a mass update is required. Invalid shapes in the batch are ignored. For best performance, the shapes should all be part of the same [PhysicsWorld](/engine/6000.7/script-reference/unity/u2d/physics/physicsworld.md), sorted by world otherwise.

```csharp
public static int SetBatchGeometry(ReadOnlySpan<PhysicsShape> shapes, CapsuleGeometry geometry)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set.**** (\[CapsuleGeometry]\(/engine/6000.7/script-reference/unity/u2d/physics/capsulegeometry)): The geometry to set on every shape.

### Returns

| Type                                                       | Description                                                                                                                    |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of shapes that were ignored (not set because the shape was invalid). If the geometry is invalid, no shapes are set. |

## SetBatchGeometry(ReadOnlySpan\<PhysicsShape>, PolygonGeometry)

Set a batch of [PhysicsShape](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape.md) all to the same [PolygonGeometry](/engine/6000.7/script-reference/unity/u2d/physics/polygongeometry.md). Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call [PhysicsBody.ApplyMassFromShapes](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/applymassfromshapes.md) on any affected body if a mass update is required. Invalid shapes in the batch are ignored. For best performance, the shapes should all be part of the same [PhysicsWorld](/engine/6000.7/script-reference/unity/u2d/physics/physicsworld.md), sorted by world otherwise.

```csharp
public static int SetBatchGeometry(ReadOnlySpan<PhysicsShape> shapes, PolygonGeometry geometry)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set.**** (\[PolygonGeometry]\(/engine/6000.7/script-reference/unity/u2d/physics/polygongeometry)): The geometry to set on every shape.

### Returns

| Type                                                       | Description                                                                                                                    |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of shapes that were ignored (not set because the shape was invalid). If the geometry is invalid, no shapes are set. |

## SetBatchGeometry(ReadOnlySpan\<PhysicsShape>, SegmentGeometry)

Set a batch of [PhysicsShape](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape.md) all to the same [SegmentGeometry](/engine/6000.7/script-reference/unity/u2d/physics/segmentgeometry.md). Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call [PhysicsBody.ApplyMassFromShapes](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/applymassfromshapes.md) on any affected body if a mass update is required. Invalid shapes in the batch are ignored. For best performance, the shapes should all be part of the same [PhysicsWorld](/engine/6000.7/script-reference/unity/u2d/physics/physicsworld.md), sorted by world otherwise.

```csharp
public static int SetBatchGeometry(ReadOnlySpan<PhysicsShape> shapes, SegmentGeometry geometry)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set.**** (\[SegmentGeometry]\(/engine/6000.7/script-reference/unity/u2d/physics/segmentgeometry)): The geometry to set on every shape.

### Returns

| Type                                                       | Description                                                                                                                    |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of shapes that were ignored (not set because the shape was invalid). If the geometry is invalid, no shapes are set. |

## SetBatchGeometry(ReadOnlySpan\<PhysicsShape>, ChainSegmentGeometry)

Set a batch of [PhysicsShape](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape.md) all to the same [ChainSegmentGeometry](/engine/6000.7/script-reference/unity/u2d/physics/chainsegmentgeometry.md). If a shape is already a chain segment, its owning chain is preserved. Like the single geometry setters, this updates the shape type and broadphase but does not update body mass. Call [PhysicsBody.ApplyMassFromShapes](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/applymassfromshapes.md) on any affected body if a mass update is required. Invalid shapes in the batch are ignored. For best performance, the shapes should all be part of the same [PhysicsWorld](/engine/6000.7/script-reference/unity/u2d/physics/physicsworld.md), sorted by world otherwise.

```csharp
public static int SetBatchGeometry(ReadOnlySpan<PhysicsShape> shapes, ChainSegmentGeometry geometry)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set.**** (\[ChainSegmentGeometry]\(/engine/6000.7/script-reference/unity/u2d/physics/chainsegmentgeometry)): The geometry to set on every shape.

### Returns

| Type                                                       | Description                                                                                                                    |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of shapes that were ignored (not set because the shape was invalid). If the geometry is invalid, no shapes are set. |
