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

参数

position屏幕上用于字段的矩形。
label(可选)字段前的标签。
selectedValue该字段显示的选项的值。
displayedOptions供用户选择的所示选项的数组。
optionValues包含每个选项值的数组。假设 optionValues 是 selectedValue 到 displayedOptions 的直接映射。
style可选 GUIStyle

返回

int 用户所选选项的值。

描述

创建一个整数弹出选择字段。

以参数形式获取当前所选的整数,并返回用户选择的整数。


编辑器窗口中的 Int 弹出菜单。

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

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

参数

position屏幕上用于字段的矩形。
property用于控件的 SerializedProperty。
displayedOptions供用户选择的所示选项的数组。
optionValues包含每个选项值的数组。假设 optionValues 是 selectedValue 到 displayedOptions 的直接映射。
label(可选)字段前的标签。

描述

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