# IntSlider

> Make a slider the user can drag to change an integer value between a min and a max.

## Definition

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

## IntSlider(int, int, int, GUILayoutOption\[])

Make a slider the user can drag to change an integer value between a min and a max.

```csharp
public static int IntSlider(int value, int leftValue, int rightValue, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value the slider shows. This determines the position of the draggable thumb.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the left end of the slider.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the right end of the slider.**** (\[GUILayoutOption\[]]\(/engine/6000.3/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.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

![EditorGUILayoutIntSlider (IntSlider)](/api/media?file=/engine/6000.3/media/images/EditorGUILayoutIntSlider.png)

*Create a grid of cloned Objects.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;

// Simple editor script that lets you clone your object in a grid

public class IntSliderExample : EditorWindow
{
    int cloneTimesX  = 1;
    int cloneTimesY  = 1;
    int cloneTimesZ  = 1;
    int spacing   = 2;

    [MenuItem("Examples/Editor GUILayout IntSlider usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(IntSliderExample));
        window.Show();
    }

    void OnGUI()
    {
        cloneTimesX = EditorGUILayout.IntSlider(cloneTimesX, 1, 10);
        cloneTimesY = EditorGUILayout.IntSlider(cloneTimesY, 1, 10);
        cloneTimesZ = EditorGUILayout.IntSlider(cloneTimesZ, 1, 10);

        if (GUILayout.Button("Duplicate object"))
            CloneSelected();
    }

    void CloneSelected()
    {
        if (!Selection.activeGameObject)
        {
            Debug.LogError("Select a GameObject first");
            return;
        }

        for (int i = 0; i < cloneTimesX; i++)
            for (int j = 0; j < cloneTimesY; j++)
                for (int k = 0; k < cloneTimesZ; k++)
                    Instantiate(Selection.activeGameObject, new Vector3(i, j, k) * spacing, Selection.activeGameObject.transform.rotation);
    }
}
```

## IntSlider(string, int, int, int, GUILayoutOption\[])

Make a slider the user can drag to change an integer value between a min and a max.

```csharp
public static int IntSlider(string label, int value, int leftValue, int rightValue, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label in front of the slider.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value the slider shows. This determines the position of the draggable thumb.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the left end of the slider.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the right end of the slider.**** (\[GUILayoutOption\[]]\(/engine/6000.3/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.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

![EditorGUILayoutIntSlider (IntSlider)](/api/media?file=/engine/6000.3/media/images/EditorGUILayoutIntSlider.png)

*Create a grid of cloned Objects.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;

// Simple editor script that lets you clone your object in a grid

public class IntSliderExample : EditorWindow
{
    int cloneTimesX  = 1;
    int cloneTimesY  = 1;
    int cloneTimesZ  = 1;
    int spacing   = 2;

    [MenuItem("Examples/Editor GUILayout IntSlider usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(IntSliderExample));
        window.Show();
    }

    void OnGUI()
    {
        cloneTimesX = EditorGUILayout.IntSlider(cloneTimesX, 1, 10);
        cloneTimesY = EditorGUILayout.IntSlider(cloneTimesY, 1, 10);
        cloneTimesZ = EditorGUILayout.IntSlider(cloneTimesZ, 1, 10);

        if (GUILayout.Button("Duplicate object"))
            CloneSelected();
    }

    void CloneSelected()
    {
        if (!Selection.activeGameObject)
        {
            Debug.LogError("Select a GameObject first");
            return;
        }

        for (int i = 0; i < cloneTimesX; i++)
            for (int j = 0; j < cloneTimesY; j++)
                for (int k = 0; k < cloneTimesZ; k++)
                    Instantiate(Selection.activeGameObject, new Vector3(i, j, k) * spacing, Selection.activeGameObject.transform.rotation);
    }
}
```

## IntSlider(GUIContent, int, int, int, GUILayoutOption\[])

Make a slider the user can drag to change an integer value between a min and a max.

```csharp
public static int IntSlider(GUIContent label, int value, int leftValue, int rightValue, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.3/script-reference/unityengine/guicontent)): Optional label in front of the slider.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value the slider shows. This determines the position of the draggable thumb.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the left end of the slider.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the right end of the slider.**** (\[GUILayoutOption\[]]\(/engine/6000.3/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.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

![EditorGUILayoutIntSlider (IntSlider)](/api/media?file=/engine/6000.3/media/images/EditorGUILayoutIntSlider.png)

*Create a grid of cloned Objects.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;

// Simple editor script that lets you clone your object in a grid

public class IntSliderExample : EditorWindow
{
    int cloneTimesX  = 1;
    int cloneTimesY  = 1;
    int cloneTimesZ  = 1;
    int spacing   = 2;

    [MenuItem("Examples/Editor GUILayout IntSlider usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(IntSliderExample));
        window.Show();
    }

    void OnGUI()
    {
        cloneTimesX = EditorGUILayout.IntSlider(cloneTimesX, 1, 10);
        cloneTimesY = EditorGUILayout.IntSlider(cloneTimesY, 1, 10);
        cloneTimesZ = EditorGUILayout.IntSlider(cloneTimesZ, 1, 10);

        if (GUILayout.Button("Duplicate object"))
            CloneSelected();
    }

    void CloneSelected()
    {
        if (!Selection.activeGameObject)
        {
            Debug.LogError("Select a GameObject first");
            return;
        }

        for (int i = 0; i < cloneTimesX; i++)
            for (int j = 0; j < cloneTimesY; j++)
                for (int k = 0; k < cloneTimesZ; k++)
                    Instantiate(Selection.activeGameObject, new Vector3(i, j, k) * spacing, Selection.activeGameObject.transform.rotation);
    }
}
```

## IntSlider(SerializedProperty, int, int, GUILayoutOption\[])

Make a slider the user can drag to change an integer value between a min and a max.

```csharp
public static void IntSlider(SerializedProperty property, int leftValue, int rightValue, params GUILayoutOption[] options)
```

### Parameters

**** (\[SerializedProperty]\(/engine/6000.3/script-reference/unityeditor/serializedproperty)): The value the slider shows. This determines the position of the draggable thumb.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the left end of the slider.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the right end of the slider.**** (\[GUILayoutOption\[]]\(/engine/6000.3/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.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).

## IntSlider(SerializedProperty, int, int, string, GUILayoutOption\[])

Make a slider the user can drag to change an integer value between a min and a max.

```csharp
public static void IntSlider(SerializedProperty property, int leftValue, int rightValue, string label, params GUILayoutOption[] options)
```

### Parameters

**** (\[SerializedProperty]\(/engine/6000.3/script-reference/unityeditor/serializedproperty)): The value the slider shows. This determines the position of the draggable thumb.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the left end of the slider.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the right end of the slider.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label in front of the slider.**** (\[GUILayoutOption\[]]\(/engine/6000.3/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.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).

## IntSlider(SerializedProperty, int, int, GUIContent, GUILayoutOption\[])

Make a slider the user can drag to change an integer value between a min and a max.

```csharp
public static void IntSlider(SerializedProperty property, int leftValue, int rightValue, GUIContent label, params GUILayoutOption[] options)
```

### Parameters

**** (\[SerializedProperty]\(/engine/6000.3/script-reference/unityeditor/serializedproperty)): The value the slider shows. This determines the position of the draggable thumb.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the left end of the slider.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The value at the right end of the slider.**** (\[GUIContent]\(/engine/6000.3/script-reference/unityengine/guicontent)): Optional label in front of the slider.**** (\[GUILayoutOption\[]]\(/engine/6000.3/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.3/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.3/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.3/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.3/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.3/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.3/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.3/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.3/script-reference/unityengine/guilayout/expandheight.md).
