# MinMaxSlider

> Makes a special slider the user can use to specify a range between a min and a max.

## Definition

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

## MinMaxSlider(GUIContent, Rect, float, float, float, float)

Makes a special slider the user can use to specify a range between a min and a max.

> **Warning:**
>
> **Deprecated.** Switch the order of the first two parameters.

```csharp
public static void MinMaxSlider(GUIContent label, Rect position, ref float minValue, ref float maxValue, float minLimit, float maxLimit)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.6/script-reference/unityengine/guicontent)): Optional label in front of the slider.**** (\[Rect]\(/engine/6000.6/script-reference/unityengine/rect)): Rectangle on the screen to use for the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The lower value of the range the slider shows, passed by reference.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The upper value at the range the slider shows, passed by reference.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The limit at the left end of the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The limit at the right end of the slider.

### Remarks

![EditorGUIMinMaxSlider (MinMaxSlider)](/api/media?file=/engine/6000.6/media/images/EditorGUIMinMaxSlider.png)

*MinMax Slider in an Editor Window.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;


// Place the selected object randomly between the interval of the Min Max Slider
// in the X,Y,Z coords

class EditorGUIMinMaxSlider : EditorWindow
{
    float minVal = -10;
    float minLimit = -20;
    float maxVal = 10;
    float maxLimit = 20;

    [MenuItem("Examples/Editor GUI Move Object Randomly")]
    static void Init()
    {
        var window = GetWindow<EditorGUIMinMaxSlider>();
        window.Show();
    }

    void OnGUI()
    {
        EditorGUI.MinMaxSlider(
            new Rect(0, 0, position.width, 20),
            new GUIContent("Random range:"),
            ref minVal, ref maxVal,
            minLimit, maxLimit);
        if (GUI.Button(new Rect(0, 25, position.width, position.height - 25), "Randomize!"))
        {
            PlaceRandomly();
        }
    }

    void PlaceRandomly()
    {
        if (Selection.activeTransform)
        {
            Selection.activeTransform.position =
                new Vector3(
                    Random.Range(minVal, maxVal),
                    Random.Range(minVal, maxVal),
                    Random.Range(minVal, maxVal)
                );
        }
        else
        {
            Debug.LogError("Select a GameObject to randomize its position.");
        }
    }
}
```

## MinMaxSlider(Rect, string, float, float, float, float)

Makes a special slider the user can use to specify a range between a min and a max.

```csharp
public static void MinMaxSlider(Rect position, string label, ref float minValue, ref float maxValue, float minLimit, float maxLimit)
```

### Parameters

**** (\[Rect]\(/engine/6000.6/script-reference/unityengine/rect)): Rectangle on the screen to use for the slider.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label in front of the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The lower value of the range the slider shows, passed by reference.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The upper value at the range the slider shows, passed by reference.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The limit at the left end of the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The limit at the right end of the slider.

### Remarks

![EditorGUIMinMaxSlider (MinMaxSlider)](/api/media?file=/engine/6000.6/media/images/EditorGUIMinMaxSlider.png)

*MinMax Slider in an Editor Window.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;


// Place the selected object randomly between the interval of the Min Max Slider
// in the X,Y,Z coords

class EditorGUIMinMaxSlider : EditorWindow
{
    float minVal = -10;
    float minLimit = -20;
    float maxVal = 10;
    float maxLimit = 20;

    [MenuItem("Examples/Editor GUI Move Object Randomly")]
    static void Init()
    {
        var window = GetWindow<EditorGUIMinMaxSlider>();
        window.Show();
    }

    void OnGUI()
    {
        EditorGUI.MinMaxSlider(
            new Rect(0, 0, position.width, 20),
            new GUIContent("Random range:"),
            ref minVal, ref maxVal,
            minLimit, maxLimit);
        if (GUI.Button(new Rect(0, 25, position.width, position.height - 25), "Randomize!"))
        {
            PlaceRandomly();
        }
    }

    void PlaceRandomly()
    {
        if (Selection.activeTransform)
        {
            Selection.activeTransform.position =
                new Vector3(
                    Random.Range(minVal, maxVal),
                    Random.Range(minVal, maxVal),
                    Random.Range(minVal, maxVal)
                );
        }
        else
        {
            Debug.LogError("Select a GameObject to randomize its position.");
        }
    }
}
```

## MinMaxSlider(Rect, GUIContent, float, float, float, float)

Makes a special slider the user can use to specify a range between a min and a max.

```csharp
public static void MinMaxSlider(Rect position, GUIContent label, ref float minValue, ref float maxValue, float minLimit, float maxLimit)
```

### Parameters

**** (\[Rect]\(/engine/6000.6/script-reference/unityengine/rect)): Rectangle on the screen to use for the slider.**** (\[GUIContent]\(/engine/6000.6/script-reference/unityengine/guicontent)): Optional label in front of the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The lower value of the range the slider shows, passed by reference.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The upper value at the range the slider shows, passed by reference.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The limit at the left end of the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The limit at the right end of the slider.

### Remarks

![EditorGUIMinMaxSlider (MinMaxSlider)](/api/media?file=/engine/6000.6/media/images/EditorGUIMinMaxSlider.png)

*MinMax Slider in an Editor Window.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;


// Place the selected object randomly between the interval of the Min Max Slider
// in the X,Y,Z coords

class EditorGUIMinMaxSlider : EditorWindow
{
    float minVal = -10;
    float minLimit = -20;
    float maxVal = 10;
    float maxLimit = 20;

    [MenuItem("Examples/Editor GUI Move Object Randomly")]
    static void Init()
    {
        var window = GetWindow<EditorGUIMinMaxSlider>();
        window.Show();
    }

    void OnGUI()
    {
        EditorGUI.MinMaxSlider(
            new Rect(0, 0, position.width, 20),
            new GUIContent("Random range:"),
            ref minVal, ref maxVal,
            minLimit, maxLimit);
        if (GUI.Button(new Rect(0, 25, position.width, position.height - 25), "Randomize!"))
        {
            PlaceRandomly();
        }
    }

    void PlaceRandomly()
    {
        if (Selection.activeTransform)
        {
            Selection.activeTransform.position =
                new Vector3(
                    Random.Range(minVal, maxVal),
                    Random.Range(minVal, maxVal),
                    Random.Range(minVal, maxVal)
                );
        }
        else
        {
            Debug.LogError("Select a GameObject to randomize its position.");
        }
    }
}
```

## MinMaxSlider(Rect, float, float, float, float)

Makes a special slider the user can use to specify a range between a min and a max.

```csharp
public static void MinMaxSlider(Rect position, ref float minValue, ref float maxValue, float minLimit, float maxLimit)
```

### Parameters

**** (\[Rect]\(/engine/6000.6/script-reference/unityengine/rect)): Rectangle on the screen to use for the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The lower value of the range the slider shows, passed by reference.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The upper value at the range the slider shows, passed by reference.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The limit at the left end of the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The limit at the right end of the slider.

### Remarks

![EditorGUIMinMaxSlider (MinMaxSlider)](/api/media?file=/engine/6000.6/media/images/EditorGUIMinMaxSlider.png)

*MinMax Slider in an Editor Window.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;


// Place the selected object randomly between the interval of the Min Max Slider
// in the X,Y,Z coords

class EditorGUIMinMaxSlider : EditorWindow
{
    float minVal = -10;
    float minLimit = -20;
    float maxVal = 10;
    float maxLimit = 20;

    [MenuItem("Examples/Editor GUI Move Object Randomly")]
    static void Init()
    {
        var window = GetWindow<EditorGUIMinMaxSlider>();
        window.Show();
    }

    void OnGUI()
    {
        EditorGUI.MinMaxSlider(
            new Rect(0, 0, position.width, 20),
            new GUIContent("Random range:"),
            ref minVal, ref maxVal,
            minLimit, maxLimit);
        if (GUI.Button(new Rect(0, 25, position.width, position.height - 25), "Randomize!"))
        {
            PlaceRandomly();
        }
    }

    void PlaceRandomly()
    {
        if (Selection.activeTransform)
        {
            Selection.activeTransform.position =
                new Vector3(
                    Random.Range(minVal, maxVal),
                    Random.Range(minVal, maxVal),
                    Random.Range(minVal, maxVal)
                );
        }
        else
        {
            Debug.LogError("Select a GameObject to randomize its position.");
        }
    }
}
```
