EditorGUILayout.MinMaxSlider 最小最大滑动条

static function MinMaxSlider (ref minValue : float, ref maxValue : float, minLimit : float, maxLimit : float, params options : GUILayoutOption[]) : void
static function MinMaxSlider (label : GUIContent, ref minValue : float, ref maxValue : float, minLimit : float, maxLimit : float, params options : GUILayoutOption[]) : void

Parameters参数

Description描述

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

制作一个特殊滑动条,用户可以使用指定的范围,在最小和最大值之间。

EditorGUILayout.MinMaxSlider 最小最大滑动条

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
//随机放置选择的物体在最小最大滑动条之间
class EditorGUILayoutMinMaxSlider extends EditorWindow {

	var minVal : float = -10;
	var minLimit : float = -20;
	var maxVal : float = 10;
	var maxLimit : float = 20;

	@MenuItem("Examples/Place Object Randomly")
	static function Init() {
		var window = GetWindow(EditorGUILayoutMinMaxSlider);
		window.Show();
	}

	function OnGUI() {
		EditorGUILayout.LabelField("Min Val:", minVal.ToString());
		EditorGUILayout.LabelField("Max Val:", maxVal.ToString());
		EditorGUILayout.MinMaxSlider(minVal, maxVal, minLimit, maxLimit);
		if(GUILayout.Button("Move!"))
			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.");
	}
}
Page last updated: 2011-7-14