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

参数

position屏幕上用于滑动条的矩形。
label(可选)滑动条前的标签。
minValue滑动条显示的范围内的下限值,按引用传递。
maxValue滑动条显示的范围内的上限值,按引用传递。
minLimit滑动条左端的限值。
maxLimit滑动条右端的限值。

描述

创建一个特殊滑动条,用户可利用该滑动条指定最小值和最大值之间的一个范围。


编辑器窗口中的 MinMax 滑动条。

// 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."); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961