Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorGUI.IntPopup

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

Parameters

positionRectangle on the screen to use for the field.
labelOptional label in front of the field.
selectedValueThe value of the option the field shows.
displayedOptionsAn array with the displayed options the user can choose from.
optionValuesAn array with the values for each option. If optionValues a direct mapping of selectedValue to displayedOptions is assumed.
styleOptional 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.


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

static function IntPopup(position: Rect, property: SerializedProperty, displayedOptions: GUIContent[], optionValues: int[], label: GUIContent = null): void;
static void IntPopup(Rect position, SerializedProperty property, GUIContent[] displayedOptions, int[] optionValues, GUIContent label = null);
static def IntPopup(position as Rect, property as SerializedProperty, displayedOptions as GUIContent[], optionValues as int[], label as GUIContent = null) as void

Parameters

positionRectangle on the screen to use for the field.
propertyThe SerializedProperty to use for the control.
displayedOptionsAn array with the displayed options the user can choose from.
optionValuesAn array with the values for each option. If optionValues a direct mapping of selectedValue to displayedOptions is assumed.
labelOptional label in front of the field.

Description