# MinMaxSlider

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

## Definition

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

## MinMaxSlider(float, float, float, float, GUILayoutOption\[])

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

```csharp
public static void MinMaxSlider(ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options)
```

### Parameters

**** (\[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.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Remarks

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

*Moves the selected object randomly betweeen the interval.*

### Examples

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

using UnityEditor;
using UnityEngine;

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

    [MenuItem("Examples/Place Object Randomly")]
    static void Init()
    {
        ExampleClass window = (ExampleClass)GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        EditorGUILayout.LabelField("Min Val:", minVal.ToString());
        EditorGUILayout.LabelField("Max Val:", maxVal.ToString());
        EditorGUILayout.MinMaxSlider(ref minVal, ref maxVal, minLimit, maxLimit);
        if (GUILayout.Button("Move!"))
            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(string, float, float, float, float, GUILayoutOption\[])

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

```csharp
public static void MinMaxSlider(string label, ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options)
```

### Parameters

**** (\[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.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Remarks

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

*Moves the selected object randomly betweeen the interval.*

### Examples

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

using UnityEditor;
using UnityEngine;

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

    [MenuItem("Examples/Place Object Randomly")]
    static void Init()
    {
        ExampleClass window = (ExampleClass)GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        EditorGUILayout.LabelField("Min Val:", minVal.ToString());
        EditorGUILayout.LabelField("Max Val:", maxVal.ToString());
        EditorGUILayout.MinMaxSlider(ref minVal, ref maxVal, minLimit, maxLimit);
        if (GUILayout.Button("Move!"))
            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(GUIContent, float, float, float, float, GUILayoutOption\[])

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

```csharp
public static void MinMaxSlider(GUIContent label, ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.7/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.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Remarks

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

*Moves the selected object randomly betweeen the interval.*

### Examples

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

using UnityEditor;
using UnityEngine;

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

    [MenuItem("Examples/Place Object Randomly")]
    static void Init()
    {
        ExampleClass window = (ExampleClass)GetWindow(typeof(ExampleClass));
        window.Show();
    }

    void OnGUI()
    {
        EditorGUILayout.LabelField("Min Val:", minVal.ToString());
        EditorGUILayout.LabelField("Max Val:", maxVal.ToString());
        EditorGUILayout.MinMaxSlider(ref minVal, ref maxVal, minLimit, maxLimit);
        if (GUILayout.Button("Move!"))
            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.");
    }
}
```
