Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

EditorGUILayout.Popup

フィードバック

ありがとうございます

この度はドキュメントの品質向上のためにご意見・ご要望をお寄せいただき、誠にありがとうございます。頂いた内容をドキュメントチームで確認し、必要に応じて修正を致します。

閉じる

送信に失敗しました

なんらかのエラーが発生したため送信が出来ませんでした。しばらく経ってから<a>もう一度送信</a>してください。ドキュメントの品質向上のために時間を割いて頂き誠にありがとうございます。

閉じる

キャンセル

マニュアルに切り替える
public static function Popup(selectedIndex: int, displayedOptions: string[], params options: GUILayoutOption[]): int;
public static int Popup(int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options);
public static function Popup(selectedIndex: int, displayedOptions: string[], style: GUIStyle, params options: GUILayoutOption[]): int;
public static int Popup(int selectedIndex, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static function Popup(selectedIndex: int, displayedOptions: GUIContent[], params options: GUILayoutOption[]): int;
public static int Popup(int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options);
public static function Popup(selectedIndex: int, displayedOptions: GUIContent[], style: GUIStyle, params options: GUILayoutOption[]): int;
public static int Popup(int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static function Popup(label: string, selectedIndex: int, displayedOptions: string[], params options: GUILayoutOption[]): int;
public static int Popup(string label, int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options);
public static function Popup(label: string, selectedIndex: int, displayedOptions: string[], style: GUIStyle, params options: GUILayoutOption[]): int;
public static int Popup(string label, int selectedIndex, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static function Popup(label: GUIContent, selectedIndex: int, displayedOptions: GUIContent[], params options: GUILayoutOption[]): int;
public static int Popup(GUIContent label, int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options);
public static function Popup(label: GUIContent, selectedIndex: int, displayedOptions: GUIContent[], style: GUIStyle, params options: GUILayoutOption[]): int;
public static int Popup(GUIContent label, int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);

パラメーター

label フィールドのラベル
selectedIndex フィールドに表示するオプションのインデックス
displayedOptions ポップアップで表示されるオプションの配列
style オプションの GUIStyle
options 特別なレイアウト対応をするためのレイアウトオプションリスト。ここに渡された値は style で定義された設定を上書きします。
See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

戻り値

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

説明

一般的なポップアップ選択フィールドを作成します。

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


"選択したオプションに応じてプリミティブのインスタンスを作成します。"


        
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user. public class EditorGUILayoutPopup : EditorWindow { public string[] options = new string[] {"Cube", "Sphere", "Plane"}; public int index = 0; [MenuItem("Examples/Editor GUILayout Popup usage")] static void Init() { EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup)); window.Show(); } void OnGUI() { index = EditorGUILayout.Popup(index, options); if (GUILayout.Button("Create")) InstantiatePrimitive(); } void InstantiatePrimitive() { switch(index) { case 0: GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.position = Vector3.zero; break; case 1: GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.position = Vector3.zero; break; case 2: GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane); plane.transform.position = Vector3.zero; break; default: Debug.LogError("Unrecognized Option"); break; } } }