# SetSurfaceMaterial

> Set the PhysicsShape.SurfaceMaterial on a batch of shapes. The shapes and surfaceMaterials spans must be the same length; shapes[n] receives surfaceMaterials[n].

## Definition

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

## SetSurfaceMaterial(ReadOnlySpan\<PhysicsShape>, ReadOnlySpan\<SurfaceMaterial>)

Set the [PhysicsShape.SurfaceMaterial](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape/surfacematerial.md) on a batch of shapes. The shapes and surfaceMaterials spans must be the same length; shapes\[n] receives surfaceMaterials\[n].

```csharp
public static int SetSurfaceMaterial(ReadOnlySpan<PhysicsShape> shapes, ReadOnlySpan<PhysicsShape.SurfaceMaterial> surfaceMaterials)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set the surface material on.**** (\[ReadOnlySpan\<SurfaceMaterial>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The surface materials to set, one entry per 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). A single warning is logged when any are ignored. If the spans are different lengths, nothing is set and every shape is counted as ignored. |

## SetSurfaceMaterial(ReadOnlySpan\<PhysicsShape>, SurfaceMaterial)

Set the same [PhysicsShape.SurfaceMaterial](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape/surfacematerial.md) on a batch of shapes.

```csharp
public static int SetSurfaceMaterial(ReadOnlySpan<PhysicsShape> shapes, PhysicsShape.SurfaceMaterial surfaceMaterial)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to set the surface material on.**** (\[SurfaceMaterial]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsshape/surfacematerial)): The surface material 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). A single warning is logged when any are ignored. |
