EditorGUI.IntPopup 整型弹出菜单

static function IntPopup (position : Rect, selectedValue : int, displayedOptions : string[], optionValues : int[], style : GUIStyle = EditorStyles.popup) : int
static function IntPopup (position : Rect, selectedValue : int, displayedOptions : GUIContent[], optionValues : int[], style : GUIStyle = EditorStyles.popup) : int
static function IntPopup (position : Rect, property : SerializedProperty, displayedOptions : GUIContent[], optionValues : int[], label : GUIContent) : void
static function IntPopup (position : Rect, label : string, selectedValue : int, displayedOptions : string[], optionValues : int[], style : GUIStyle = EditorStyles.popup) : int
static function IntPopup (position : Rect, label : GUIContent, selectedValue : int, displayedOptions : GUIContent[], optionValues : int[], style : GUIStyle = EditorStyles.popup) : int

Parameters参数

Returns

int - The value of the option that has been selected by the user.

返回整数 - 用户选择的选项的索引值

Description描述

Make an integer popup selection field.

 制作一个整型弹出选择菜单。

Takes the currently selected integer as a parameter and returns the integer selected by the user.

使用当前的整数作为参数并返回用户选择的整数

EditorGUI.IntPopup 整数弹出菜单

Int Popup in an Editor Window.
编辑器中的整型弹出菜单。

// Multiplies the scale of the selected transform.
//乘以选择的变换的比例值。

class EditorGUIIntPopup extends EditorWindow {

	var selectedSize : int = 1;
	var names : String[] = ["Double", "Triple", "Quadruple"];
	var sizes : int[] = [2,3,4];

	@MenuItem("Examples/Editor GUI Int Popup usage")
	static function Init() {
		var window = GetWindow(EditorGUIIntPopup);
		window.position = Rect(0,0,180,60);
		window.Show();
	}
	function OnGUI() {
		selectedSize = EditorGUI.IntPopup(
			Rect(3,3,position.width - 6,20),
			"Size:",
			selectedSize,
			names,
			sizes);
		if(GUI.Button(Rect(0,25,position.width,position.height - 27), "Modify"))
			Rescale();
	}
	function Rescale() {
		if(Selection.activeTransform)
			Selection.activeTransform.localScale *= selectedSize;
		else
			Debug.LogError("No Object selected, please select an object to scale.");
	}
}
最后修改:2011年6月22日 Wednesday 17:46

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。