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参数

  • position
    Rectangle on the screen to use for the field.
    屏幕上的矩形区域    
  • label
    Optional label in front of the field.
    显示在该区域前面的可选择标签    
  • selectedValue
    The value of the option the field shows.
       显示字段选项的值    
  • displayedOptions
    An array with the displayed options the user can choose from.
    显示的选项数组供用户选择
  • style
    Optional GUIStyle. //  可选的GUIStyle

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;elseDebug.LogError("No Object selected, please select an object to scale.");}}


,