Version: 5.5 (switch to 5.6b)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorGUI.MinMaxSlider

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete public static function MinMaxSlider(label: GUIContent, position: Rect, ref minValue: float, ref maxValue: float, minLimit: float, maxLimit: float): void;
Obsolete public static void MinMaxSlider(GUIContent label, Rect position, ref float minValue, ref float maxValue, float minLimit, float maxLimit);
public static function MinMaxSlider(position: Rect, ref minValue: float, ref maxValue: float, minLimit: float, maxLimit: float): void;
public static void MinMaxSlider(Rect position, ref float minValue, ref float maxValue, float minLimit, float maxLimit);
public static function MinMaxSlider(position: Rect, label: string, ref minValue: float, ref maxValue: float, minLimit: float, maxLimit: float): void;
public static void MinMaxSlider(Rect position, string label, ref float minValue, ref float maxValue, float minLimit, float maxLimit);
public static function MinMaxSlider(position: Rect, label: GUIContent, ref minValue: float, ref maxValue: float, minLimit: float, maxLimit: float): void;
public static void MinMaxSlider(Rect position, GUIContent label, ref float minValue, ref float maxValue, float minLimit, float maxLimit);

Parameters

position Rectangle on the screen to use for the slider.
label Optional label in front of the slider.
minValue The lower value of the range the slider shows, passed by reference.
maxValue The upper value at the range the slider shows, passed by reference.
minLimit The limit at the left end of the slider.
maxLimit The limit at the right end of the slider.

Description

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


MinMax Slider in an Editor Window.

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

class EditorGUIMinMaxSlider extends EditorWindow {

var minVal : float = -10; var minLimit : float = -20; var maxVal : float = 10; var maxLimit : float = 20; @MenuItem("Examples/Editor GUI Move Object Randomly") static function Init() { var window = GetWindow(EditorGUIMinMaxSlider); window.Show(); } function OnGUI() { EditorGUI.MinMaxSlider( Rect(0,0,position.width,20), GUIContent("Random range:"), minVal, maxVal, minLimit, maxLimit); if(GUI.Button(Rect(0,25,position.width, position.height -25),"Randomize!")) PlaceRandomly(); } function PlaceRandomly() { if(Selection.activeTransform) Selection.activeTransform.position = Vector3(Random.Range(minVal, maxVal), Random.Range(minVal, maxVal), Random.Range(minVal, maxVal)); else Debug.LogError("Select a GameObject to randomize its position."); } }