Version: 2022.3
言語: 日本語
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 の場合、 displayedOptions に selectedValue を直接マッピングすると見なされます。
style オプションの GUIStyle

戻り値

int ユーザーによって設定された値

説明

Makes an integer popup selection field.

現在選択されている整数をパラメーターとして受け取り、ユーザーによって選択された整数を返します。


Int Popup in an Editor Window.

using UnityEngine;
using UnityEditor;

// Multiplies the scale of the selected transform.

class EditorGUIIntPopup : EditorWindow { int selectedSize = 1; string[] names = { "Double", "Triple", "Quadruple" }; int[] sizes = { 2, 3, 4 };

[MenuItem("Examples/Editor GUI Int Popup usage")] static void Init() { EditorWindow window = GetWindow<EditorGUIIntPopup>(); window.position = new Rect(0, 0, 180, 60); window.Show(); }

void OnGUI() { selectedSize = EditorGUI.IntPopup( new Rect(3, 3, position.width - 6, 20), "Size:", selectedSize, names, sizes);

if (GUI.Button(new Rect(0, 25, position.width, position.height - 27), "Modify")) { Rescale(); } }

void 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 An array with the values for each option. If optionValues a direct mapping of selectedValue to displayedOptions is assumed.
label フィールドのラベル

説明