# SetMinMax

> Sets the bounds to the min and max value of the box.

## Definition

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

## SetMinMax(Vector3, Vector3)

Sets the bounds to the `min` and `max` value of the box.

```csharp
public void SetMinMax(Vector3 min, Vector3 max)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): **** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)):&#x20;

### Remarks

Using this function is faster than assigning `min` and `max` separately.

### Examples

```csharp
using UnityEngine;

[ExecuteAlways]
public class BoundsSetMinMaxExample : MonoBehaviour
{
    // These represent the corners of the box in world space.
    // 'min' is the corner with the smallest X, Y, and Z values — typically bottom-left-back.
    // 'max' is the corner with the largest X, Y, and Z values — typically top-right-front.
    public Vector3 min = new Vector3(-1, -1, -1); // Bottom-left-back
    public Vector3 max = new Vector3(1, 1, 1);    // Top-right-front
    public Color gizmoColor = Color.cyan;

    private Bounds bounds;

    void Update()
    {
        // Sets the bounds using the min (smallest XYZ) and max (largest XYZ) corners
        bounds.SetMinMax(min, max);
    }

    void OnDrawGizmos()
    {
        // Draw the bounding box as a wireframe cube in the Scene view
        Gizmos.color = gizmoColor;
        Gizmos.DrawWireCube(bounds.center, bounds.size);

        // Optional: draw small spheres at min and max points for visual clarity
        Gizmos.color = Color.red;
        Gizmos.DrawSphere(min, 0.1f); // Bottom-left-back (min)
        Gizmos.color = Color.green;
        Gizmos.DrawSphere(max, 0.1f); // Top-right-front (max)
    }
}
```

## SetMinMax(Vector3, Vector3)

Sets the bounds to the `min` and `max` value of the box.

```csharp
public void SetMinMax(in Vector3 min, in Vector3 max)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): **** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)):&#x20;

### Remarks

Using this function is faster than assigning `min` and `max` separately.

### Examples

```csharp
using UnityEngine;

[ExecuteAlways]
public class BoundsSetMinMaxExample : MonoBehaviour
{
    // These represent the corners of the box in world space.
    // 'min' is the corner with the smallest X, Y, and Z values — typically bottom-left-back.
    // 'max' is the corner with the largest X, Y, and Z values — typically top-right-front.
    public Vector3 min = new Vector3(-1, -1, -1); // Bottom-left-back
    public Vector3 max = new Vector3(1, 1, 1);    // Top-right-front
    public Color gizmoColor = Color.cyan;

    private Bounds bounds;

    void Update()
    {
        // Sets the bounds using the min (smallest XYZ) and max (largest XYZ) corners
        bounds.SetMinMax(min, max);
    }

    void OnDrawGizmos()
    {
        // Draw the bounding box as a wireframe cube in the Scene view
        Gizmos.color = gizmoColor;
        Gizmos.DrawWireCube(bounds.center, bounds.size);

        // Optional: draw small spheres at min and max points for visual clarity
        Gizmos.color = Color.red;
        Gizmos.DrawSphere(min, 0.1f); // Bottom-left-back (min)
        Gizmos.color = Color.green;
        Gizmos.DrawSphere(max, 0.1f); // Top-right-front (max)
    }
}
```
