# HorizontalSlider

> A horizontal slider the user can drag to change a value between a min and a max.

## Definition

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

## HorizontalSlider(Rect, float, float, float)

A horizontal slider the user can drag to change a value between a min and a max.

```csharp
public static float HorizontalSlider(Rect position, float value, float leftValue, float rightValue)
```

### Parameters

**** (\[Rect]\(/engine/6000.7/script-reference/unityengine/rect)): Rectangle on the screen to use for the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The value the slider shows. This determines the position of the draggable thumb.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The value at the left end of the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The value at the right end of the slider.

### Returns

| Type                                                          | Description                              |
| ------------------------------------------------------------- | ---------------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | The value that has been set by the user. |

### Examples

```csharp
 // Draws a horizontal slider control that goes from 0 to 10.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    public float hSliderValue = 0.0F;

    void OnGUI()
    {
        hSliderValue = GUI.HorizontalSlider(new Rect(25, 25, 100, 30), hSliderValue, 0.0F, 10.0F);
    }
}
```

## HorizontalSlider(Rect, float, float, float, GUIStyle, GUIStyle)

A horizontal slider the user can drag to change a value between a min and a max.

```csharp
public static float HorizontalSlider(Rect position, float value, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb)
```

### Parameters

**** (\[Rect]\(/engine/6000.7/script-reference/unityengine/rect)): Rectangle on the screen to use for the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The value the slider shows. This determines the position of the draggable thumb.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The value at the left end of the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The value at the right end of the slider.**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): The [GUIStyle](/engine/6000.7/script-reference/unityengine/guistyle.md) to use for displaying the dragging area. If left out, the `horizontalSlider` style from the current [GUISkin](/engine/6000.7/script-reference/unityengine/guiskin.md) is used.**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): The [GUIStyle](/engine/6000.7/script-reference/unityengine/guistyle.md) to use for displaying draggable thumb. If left out, the `horizontalSliderThumb` style from the current [GUISkin](/engine/6000.7/script-reference/unityengine/guiskin.md) is used.

### Returns

| Type                                                          | Description                              |
| ------------------------------------------------------------- | ---------------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | The value that has been set by the user. |

### Examples

```csharp
 // Draws a horizontal slider control that goes from 0 to 10.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    public float hSliderValue = 0.0F;

    void OnGUI()
    {
        hSliderValue = GUI.HorizontalSlider(new Rect(25, 25, 100, 30), hSliderValue, 0.0F, 10.0F);
    }
}
```

## HorizontalSlider(Rect, float, float, float, GUIStyle, GUIStyle, GUIStyle)

A horizontal slider the user can drag to change a value between a min and a max.

```csharp
public static float HorizontalSlider(Rect position, float value, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb, GUIStyle thumbExtent)
```

### Parameters

**** (\[Rect]\(/engine/6000.7/script-reference/unityengine/rect)): Rectangle on the screen to use for the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The value the slider shows. This determines the position of the draggable thumb.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The value at the left end of the slider.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The value at the right end of the slider.**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): **** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): **** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)):&#x20;

### Returns

| Type                                                          | Description                              |
| ------------------------------------------------------------- | ---------------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | The value that has been set by the user. |

### Examples

```csharp
 // Draws a horizontal slider control that goes from 0 to 10.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    public float hSliderValue = 0.0F;

    void OnGUI()
    {
        hSliderValue = GUI.HorizontalSlider(new Rect(25, 25, 100, 30), hSliderValue, 0.0F, 10.0F);
    }
}
```
