Version: 2019.2
public static void MinMaxSlider (ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options);
public static void MinMaxSlider (string label, ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options);
public static void MinMaxSlider (GUIContent label, ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options);

パラメーター

labelスライダーの前のオプションのラベル
minValueスライダーが示す範囲の下限の値はレファレンスから渡されます。
maxValueスライダーが示す範囲の上限の値はレファレンスから渡されます。
minLimit最小値
maxLimit最大値
options指定してレイアウトオプションを渡すときのレイアウトオプションのリスト。ここで設定したものは style によって設定された値を上書きします。
See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

説明

ユーザーが最小と最大の間の範囲を指定して使用できる特別なスライダーを作成します。


Moves the selected object randomly betweeen the interval.

// 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."); } }