# Snap

> Rounds value to the closest multiple of snap.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.6/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## Snap(float, float)

Rounds `value` to the closest multiple of `snap`.

```csharp
public static float Snap(float val, float snap)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The value to round.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The increment to round to.

### Returns

| Type                                                          | Description        |
| ------------------------------------------------------------- | ------------------ |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | The rounded value. |

## Snap(Vector2, Vector2)

Rounds `value` to the closest multiple of `snap`.

```csharp
public static Vector2 Snap(Vector2 val, Vector2 snap)
```

### Parameters

**** (\[Vector2]\(/engine/6000.6/script-reference/unityengine/vector2)): The value to round.**** (\[Vector2]\(/engine/6000.6/script-reference/unityengine/vector2)): The increment to round to.

### Returns

| Type                                                              | Description        |
| ----------------------------------------------------------------- | ------------------ |
| [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md) | The rounded value. |

## Snap(Vector3, Vector3, SnapAxis)

Rounds `value` to the closest multiple of `snap`.

```csharp
public static Vector3 Snap(Vector3 val, Vector3 snap, SnapAxis axis = SnapAxis.All)
```

### Parameters

**** (\[Vector3]\(/engine/6000.6/script-reference/unityengine/vector3)): The value to round.**** (\[Vector3]\(/engine/6000.6/script-reference/unityengine/vector3)): The increment to round to.**** (\[SnapAxis]\(/engine/6000.6/script-reference/unityengine/snapaxis)): Restrict snapping to the components on these axes.

### Returns

| Type                                                              | Description        |
| ----------------------------------------------------------------- | ------------------ |
| [Vector3](/engine/6000.6/script-reference/unityengine/vector3.md) | The rounded value. |
