Editor拡張作成時に利用できる Field のまとめ
説明が必要そうなものには説明を追記します
EditorGUILayout > EditorGUI > GUILayout で無いもの順に記述しています
- GUILayout
- EditorGUI
- EditorGUILayout
- EditorGUILayout.BoundsField
- EditorGUILayout.BoundsIntField
- EditorGUILayout.ColorField
- EditorGUILayout.CurveField
- EditorGUILayout.DelayedDoubleField
- EditorGUILayout.DelayedFloatField
- EditorGUILayout.DelayedIntField
- EditorGUILayout.DelayedTextField
- EditorGUILayout.DoubleField
- EditorGUILayout.DropdownButton
- EditorGUILayout.EnumFlagsField
- EditorGUILayout.EnumPopup
- EditorGUILayout.FloatField
- EditorGUILayout.Foldout
- EditorGUILayout.GradientField
- EditorGUILayout.HelpBox
- EditorGUILayout.IntField
- EditorGUILayout.IntPopup
- EditorGUILayout.IntSlider
- EditorGUILayout.LabelField
- EditorGUILayout.LayerField
- EditorGUILayout.LongField
- EditorGUILayout.MaskField
- EditorGUILayout.MinMaxSlider
- EditorGUILayout.ObjectField
- EditorGUILayout.PasswordField
- EditorGUILayout.Popup
- EditorGUILayout.PrefixLabel
- EditorGUILayout.RectField
- EditorGUILayout.RectIntField
- EditorGUILayout.SelectableLabel
- EditorGUILayout.Slider
- EditorGUILayout.TagField
- EditorGUILayout.TextArea
- EditorGUILayout.TextField
- EditorGUILayout.Toggle
- EditorGUILayout.ToggleLeft
- EditorGUILayout.Vector2Field
- EditorGUILayout.Vector2IntField
- EditorGUILayout.Vector3Field
- EditorGUILayout.Vector3IntField
- EditorGUILayout.Vector4Field
GUILayout
GUILayout.FlexibleSpace
public static void FlexibleSpace ();
GUILayout なので EditorGUILayout.LabelField を利用した場合ズレが生じるので注意
private void OnGUI() { using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("Left"); GUILayout.FlexibleSpace(); GUILayout.Label("Center"); GUILayout.FlexibleSpace(); GUILayout.Label("Right"); } }
GUILayout.Space
public static void Space (float pixels);
private void OnGUI() { EditorGUILayout.LabelField("label1"); GUILayout.Space(10); EditorGUILayout.LabelField("label2"); GUILayout.Space(20); EditorGUILayout.LabelField("label3"); }
GUILayout.SelectionGrid
public static int SelectionGrid (int selected, string[] texts, int xCount, params GUILayoutOption[] options);
public static int SelectionGrid (int selected, Texture[] images, int xCount, params GUILayoutOption[] options);
public static int SelectionGrid (int selected, GUIContent[] content, int xCount, params GUILayoutOption[] options);
public static int SelectionGrid (int selected, string[] texts, int xCount, GUIStyle style, params GUILayoutOption[] options);
public static int SelectionGrid (int selected, Texture[] images, int xCount, GUIStyle style, params GUILayoutOption[] options);
public static int SelectionGrid (int selected, GUIContent[] contents, int xCount, GUIStyle style, params GUILayoutOption[] options);
1行あたりの数が決められる選択ボタン
private int _gridSelectIndex; private static readonly string[] GridItems = new string[] { "1", "2", "3", "4", "5", "6" }; private void OnGUI() { _gridSelectIndex = GUILayout.SelectionGrid(_gridSelectIndex, GridItems, 3); }
GUILayout.Button
public static bool Button (Texture image, params GUILayoutOption[] options);
public static bool Button (string text, params GUILayoutOption[] options);
public static bool Button (GUIContent content, params GUILayoutOption[] options);
public static bool Button (Texture image, GUIStyle style, params GUILayoutOption[] options);
public static bool Button (string text, GUIStyle style, params GUILayoutOption[] options);
public static bool Button (GUIContent content, GUIStyle style, params GUILayoutOption[] options);
private void OnGUI() { if (GUILayout.Button("Button")) { Debug.Log("Button Click"); } }
GUILayout.RepeatButton
public static bool RepeatButton (Texture image, params GUILayoutOption[] options);
public static bool RepeatButton (string text, params GUILayoutOption[] options);
public static bool RepeatButton (GUIContent content, params GUILayoutOption[] options);
public static bool RepeatButton (Texture image, GUIStyle style, params GUILayoutOption[] options);
public static bool RepeatButton (string text, GUIStyle style, params GUILayoutOption[] options);
public static bool RepeatButton (GUIContent content, GUIStyle style, params GUILayoutOption[] options);
クリックしている間 true を返すボタン
private void OnGUI() { if (GUILayout.RepeatButton("Repeat Button")) { Debug.Log("Clicking"); } }
EditorGUI
EditorGUI.ProgressBar
public static void ProgressBar (Rect position, float value, string text);
private void OnGUI() { var rect = GUILayoutUtility.GetRect(position.width, EditorGUIUtility.singleLineHeight); rect.xMin += 4; rect.xMax -= 4; EditorGUI.ProgressBar(rect, 40 / 100f, "Progress"); }
EditorGUI.MultiFloatField
public static void MultiFloatField (Rect position, GUIContent[] subLabels, float[] values);
public static void MultiFloatField (Rect position, GUIContent label, GUIContent[] subLabels, float[] values);
Float値を複数扱えるフィールド、subLabelsの幅は1文字分しかないので注意
private static readonly GUIContent LabelContents = new GUIContent("MultiFloat"); private static readonly GUIContent[] Contents = new GUIContent[] { new GUIContent("x"), new GUIContent("y"), new GUIContent("z"), }; private float[] _floatArray = new float[3]; private float _x, _y, _z; private void OnGUI() { var rect = GUILayoutUtility.GetRect(position.width, EditorGUIUtility.singleLineHeight); rect.xMin += 4; rect.xMax -= 4; _floatArray[0] = _x; _floatArray[1] = _y; _floatArray[2] = _z; EditorGUI.MultiFloatField(rect, LabelContents, Contents, _floatArray); }
EditorGUI.MultiIntField
public static void MultiIntField (Rect position, GUIContent[] subLabels, int[] values);
なぜかMultiFloatField
と違い label が無い
private static readonly GUIContent[] Contents = new GUIContent[] { new GUIContent("a"), new GUIContent("b"), }; private int[] _intArray = new int[2]; private int _a, _b; private void OnGUI() { var rect = GUILayoutUtility.GetRect(position.width, EditorGUIUtility.singleLineHeight); rect.xMin += 4; rect.xMax -= 4; _intArray[0] = _a; _intArray[1] = _b; EditorGUI.MultiIntField(rect, Contents, _intArray); }
EditorGUILayout
EditorGUILayout.BoundsField
public static Bounds BoundsField (Bounds value, params GUILayoutOption[] options);
public static Bounds BoundsField (string label, Bounds value, params GUILayoutOption[] options);
public static Bounds BoundsField (GUIContent label, Bounds value, params GUILayoutOption[] options);
private Bounds _bounds; private void OnGUI() { _bounds = EditorGUILayout.BoundsField("Bounds", _bounds); }
EditorGUILayout.BoundsIntField
public static BoundsInt BoundsIntField (BoundsInt value, params GUILayoutOption[] options);
public static BoundsInt BoundsIntField (string label, BoundsInt value, params GUILayoutOption[] options);
public static BoundsInt BoundsIntField (GUIContent label, BoundsInt value, params GUILayoutOption[] options);
private BoundsInt _boundsInt; private void OnGUI() { _boundsInt = EditorGUILayout.BoundsIntField("BoundsInt", _boundsInt); }
EditorGUILayout.ColorField
public static Color ColorField (Color value, params GUILayoutOption[] options);
public static Color ColorField (string label, Color value, params GUILayoutOption[] options);
public static Color ColorField (GUIContent label, Color value, params GUILayoutOption[] options);
public static Color ColorField (GUIContent label, Color value, bool showEyedropper, bool showAlpha, bool hdr, ColorPickerHDRConfig hdrConfig, params GUILayoutOption[] options);
Preference/General/macOS Color Picker
を True にすると Mac OS のカラーピッカーを表示できる
private Color _color = Color.white; private void OnGUI() { _color = EditorGUILayout.ColorField("Color", _color); }
EditorGUILayout.CurveField
public static AnimationCurve CurveField (AnimationCurve value, params GUILayoutOption[] options);
public static AnimationCurve CurveField (string label, AnimationCurve value, params GUILayoutOption[] options);
public static AnimationCurve CurveField (GUIContent label, AnimationCurve value, params GUILayoutOption[] options);
public static AnimationCurve CurveField (AnimationCurve value, Color color, Rect ranges, params GUILayoutOption[] options);
public static AnimationCurve CurveField (string label, AnimationCurve value, Color color, Rect ranges, params GUILayoutOption[] options);
public static AnimationCurve CurveField (GUIContent label, AnimationCurve value, Color color, Rect ranges, params GUILayoutOption[] options);
private AnimationCurve _animationCurve = new AnimationCurve(); private void OnGUI() { _animationCurve = EditorGUILayout.CurveField("Curve", _animationCurve); }
EditorGUILayout.DelayedDoubleField
public static double DelayedDoubleField (double value, params GUILayoutOption[] options);
public static double DelayedDoubleField (double value, GUIStyle style, params GUILayoutOption[] options);
public static double DelayedDoubleField (string label, double value, params GUILayoutOption[] options);
public static double DelayedDoubleField (string label, double value, GUIStyle style, params GUILayoutOption[] options);
public static double DelayedDoubleField (GUIContent label, double value, params GUILayoutOption[] options);
public static double DelayedDoubleField (GUIContent label, double value, GUIStyle style, params GUILayoutOption[] options);
エンターを押すか、入力フィールドからフォーカスを移動するまで、戻り値が変更されないフィールド
private double _doubleValue; private void OnGUI() { _doubleValue = EditorGUILayout.DelayedDoubleField("DelayedDouble", _doubleValue); }
EditorGUILayout.DelayedFloatField
public static float DelayedFloatField(float value, params GUILayoutOption[] options);
public static float DelayedFloatField(float value, GUIStyle style, params GUILayoutOption[] options);
public static float DelayedFloatField(string label, float value, params GUILayoutOption[] options);
public static float DelayedFloatField(string label, float value, GUIStyle style, params GUILayoutOption[] options);
public static float DelayedFloatField(GUIContent label, float value, params GUILayoutOption[] options);
public static float DelayedFloatField(GUIContent label, float value, GUIStyle style, params GUILayoutOption[] options);
エンターを押すか、入力フィールドからフォーカスを移動するまで、戻り値が変更されないフィールド
private float _floatValue; private void OnGUI() { _floatValue = EditorGUILayout.DelayedFloatField("DelayedFloat", _floatValue); }
EditorGUILayout.DelayedIntField
public static int DelayedIntField (int value, params GUILayoutOption[] options);
public static int DelayedIntField (int value, GUIStyle style, params GUILayoutOption[] options);
public static int DelayedIntField (string label, int value, params GUILayoutOption[] options);
public static int DelayedIntField (string label, int value, GUIStyle style, params GUILayoutOption[] options);
public static int DelayedIntField (GUIContent label, int value, params GUILayoutOption[] options);
public static int DelayedIntField (GUIContent label, int value, GUIStyle style, params GUILayoutOption[] options);
エンターを押すか、入力フィールドからフォーカスを移動するまで、戻り値が変更されないフィールド
private int _intValue; private void OnGUI() { _intValue = EditorGUILayout.DelayedIntField("DelayedInt", _intValue); }
EditorGUILayout.DelayedTextField
public static string DelayedTextField(string text, params GUILayoutOption[] options);
public static string DelayedTextField(string text, GUIStyle style, params GUILayoutOption[] options);
public static string DelayedTextField(string label, string text, params GUILayoutOption[] options);
public static string DelayedTextField(string label, string text, GUIStyle style, params GUILayoutOption[] options);
public static string DelayedTextField(GUIContent label, string text, params GUILayoutOption[] options);
public static string DelayedTextField(GUIContent label, string text, GUIStyle style, params GUILayoutOption[] options);
エンターを押すか、入力フィールドからフォーカスを移動するまで、戻り値が変更されないフィールド
private string _text; private void OnGUI() { _text = EditorGUILayout.DelayedTextField("DelayedText", _text); }
EditorGUILayout.DoubleField
public static double DoubleField(double value, params GUILayoutOption[] options);
public static double DoubleField(double value, GUIStyle style, params GUILayoutOption[] options);
public static double DoubleField(string label, double value, params GUILayoutOption[] options);
public static double DoubleField(string label, double value, GUIStyle style, params GUILayoutOption[] options);
public static double DoubleField(GUIContent label, double value, params GUILayoutOption[] options);
public static double DoubleField(GUIContent label, double value, GUIStyle style, params GUILayoutOption[] options);
private double _doubleValue; private void OnGUI() { _doubleValue = EditorGUILayout.DoubleField("Double", _doubleValue); }
EditorGUILayout.DropdownButton
public static bool DropdownButton (GUIContent content, FocusType focusType, params GUILayoutOption[] options);
public static bool DropdownButton (GUIContent content, FocusType focusType, GUIStyle style, params GUILayoutOption[] options);
PopupWindowを出すためのボタン
FocusType
は FocusType.Keyboard
と FocusType.Passive
が指定でき
FocusType.Keyboard
にすると Tab を押した際にフォーカスが当たるようになり、Space を押すことでボタンをクリックできる
private void OnGUI() { if (EditorGUILayout.DropdownButton(new GUIContent("DropDown"), FocusType.Keyboard)) { // Show PopupWindow var rect = GUILayoutUtility.GetLastRect(); rect.y += EditorGUIUtility.singleLineHeight; PopupWindow.Show(rect, new PopupSample()); } } private class PopupSample : PopupWindowContent { public override void OnGUI(Rect rect) { EditorGUILayout.LabelField("Label"); } public override Vector2 GetWindowSize() { return new Vector2(100f, EditorGUIUtility.singleLineHeight); } }
EditorGUILayout.EnumFlagsField
public static Enum EnumFlagsField(Enum enumValue, params GUILayoutOption[] options);
public static Enum EnumFlagsField(Enum enumValue, GUIStyle style, params GUILayoutOption[] options);
public static Enum EnumFlagsField(string label, Enum enumValue, params GUILayoutOption[] options);
public static Enum EnumFlagsField(string label, Enum enumValue, GUIStyle style, params GUILayoutOption[] options);
public static Enum EnumFlagsField(GUIContent label, Enum enumValue, params GUILayoutOption[] options);
public static Enum EnumFlagsField(GUIContent label, Enum enumValue, GUIStyle style, params GUILayoutOption[] options);
public static Enum EnumFlagsField(GUIContent label, Enum enumValue, bool includeObsolete, params GUILayoutOption[] options);
public static Enum EnumFlagsField(GUIContent label, Enum enumValue, bool includeObsolete, GUIStyle style, params GUILayoutOption[] options);
enum に System.FlagsAttribute
を適用しているときに利用する
[System.Flags] private enum SampleType { A = 1 << 0, B = 1 << 1, C = 1 << 2, D = 1 << 3, E = 1 << 4, } private SampleType _type; private void OnGUI() { _type = (SampleType) EditorGUILayout.EnumFlagsField("EnumFlag", _type); }
EditorGUILayout.EnumPopup
public static Enum EnumPopup (Enum selected, params GUILayoutOption[] options);
public static Enum EnumPopup (Enum selected, GUIStyle style, params GUILayoutOption[] options);
public static Enum EnumPopup (string label, Enum selected, params GUILayoutOption[] options);
public static Enum EnumPopup (string label, Enum selected, GUIStyle style, params GUILayoutOption[] options);
public static Enum EnumPopup (GUIContent label, Enum selected, params GUILayoutOption[] options);
public static Enum EnumPopup (GUIContent label, Enum selected, GUIStyle style, params GUILayoutOption[] options);
private enum SampleType { A, B, C, D, E, } private SampleType _type; private void OnGUI() { _type = (SampleType) EditorGUILayout.EnumPopup("EnumPopup", _type); }
EditorGUILayout.FloatField
public static float FloatField(GUIContent label, float value, GUIStyle style, params GUILayoutOption[] options);
private float _floatValue; private void OnGUI() { _floatValue = EditorGUILayout.FloatField("float", _floatValue); }
EditorGUILayout.Foldout
public static bool Foldout (bool foldout, string content, bool toggleOnLabelClick, GUIStyle style= EditorStyles.foldout);
public static bool Foldout (bool foldout, GUIContent content, bool toggleOnLabelClick, GUIStyle style= EditorStyles.foldout);
public static bool Foldout (bool foldout, string content, GUIStyle style= EditorStyles.foldout);
public static bool Foldout (bool foldout, GUIContent content, GUIStyle style= EditorStyles.foldout);
Foldout (折込ページ) を作れる
SerializedProperty.isExpand で利用することが多い
private bool _foldout; private void OnGUI() { _foldout = EditorGUILayout.Foldout(_foldout, "Foldout"); if (_foldout) { using (new EditorGUI.IndentLevelScope(1)) { EditorGUILayout.LabelField("Open"); } } }
EditorGUILayout.GradientField
public static Gradient GradientField(Gradient value, params GUILayoutOption[] options);
public static Gradient GradientField(string label, Gradient value, params GUILayoutOption[] options);
public static Gradient GradientField(GUIContent label, Gradient value, params GUILayoutOption[] options);
public static Gradient GradientField(GUIContent label, Gradient value, bool hdr, params GUILayoutOption[] options);
private Gradient _gradient = new Gradient(); private void OnGUI() { _gradient = EditorGUILayout.GradientField("Gradient", _gradient); for (var i = 0f; i <= 1f; i += 0.2f) { GUI.color = _gradient.Evaluate(i); GUILayout.Button(i.ToString()); } }
EditorGUILayout.HelpBox
public static void HelpBox (string message, MessageType type);
public static void HelpBox (string message, MessageType type, bool wide);
private void OnGUI() { EditorGUILayout.HelpBox("None Icon Message", MessageType.None); EditorGUILayout.HelpBox("Info Message", MessageType.Info); EditorGUILayout.HelpBox("Warning Message", MessageType.Warning); EditorGUILayout.HelpBox("Error Message", MessageType.Error); EditorGUILayout.HelpBox("None Icon Message", MessageType.None, false); EditorGUILayout.HelpBox("Info Message", MessageType.Info, false); EditorGUILayout.HelpBox("Warning Message", MessageType.Warning, false); EditorGUILayout.HelpBox("Error Message", MessageType.Error, false); }
EditorGUILayout.IntField
public static int IntField (int value, params GUILayoutOption[] options);
public static int IntField (int value, GUIStyle style, params GUILayoutOption[] options);
public static int IntField (string label, int value, params GUILayoutOption[] options);
public static int IntField (string label, int value, GUIStyle style, params GUILayoutOption[] options);
public static int IntField (GUIContent label, int value, params GUILayoutOption[] options);
public static int IntField (GUIContent label, int value, GUIStyle style, params GUILayoutOption[] options);
private int _intValue; private void OnGUI() { _intValue = EditorGUILayout.IntField("Int", _intValue); }
EditorGUILayout.IntPopup
public static int IntPopup (int selectedValue, string[] displayedOptions, int[] optionValues, params GUILayoutOption[] options);
public static int IntPopup (int selectedValue, string[] displayedOptions, int[] optionValues, GUIStyle style, params GUILayoutOption[] options);
public static int IntPopup (int selectedValue, GUIContent[] displayedOptions, int[] optionValues, params GUILayoutOption[] options);
public static int IntPopup (int selectedValue, GUIContent[] displayedOptions, int[] optionValues, GUIStyle style, params GUILayoutOption[] options);
public static int IntPopup (string label, int selectedValue, string[] displayedOptions, int[] optionValues, params GUILayoutOption[] options);
public static int IntPopup (string label, int selectedValue, string[] displayedOptions, int[] optionValues, GUIStyle style, params GUILayoutOption[] options);
public static int IntPopup (GUIContent label, int selectedValue, GUIContent[] displayedOptions, int[] optionValues, params GUILayoutOption[] options);
public static int IntPopup (GUIContent label, int selectedValue, GUIContent[] displayedOptions, int[] optionValues, GUIStyle style, params GUILayoutOption[] options);
private int _selectValue; private static readonly string[] _names = new string[] { "2^0", "2^1", "2^2", "2^3", }; private static readonly int[] _values = new int[] { 1, 2, 4, 8, }; private void OnGUI() { _selectValue = EditorGUILayout.IntPopup("exponent of 2", _selectValue, _names, _values); EditorGUILayout.LabelField(_selectValue.ToString()); }
EditorGUILayout.IntSlider
public static int IntSlider (int value, int leftValue, int rightValue, params GUILayoutOption[] options);
public static int IntSlider (string label, int value, int leftValue, int rightValue, params GUILayoutOption[] options);
public static int IntSlider (GUIContent label, int value, int leftValue, int rightValue, params GUILayoutOption[] options);
private int _intValue; private void OnGUI() { _intValue = EditorGUILayout.IntSlider("IntSlider", _intValue, 0, 100); }
EditorGUILayout.LabelField
public static void LabelField (string label, params GUILayoutOption[] options);
public static void LabelField (string label, GUIStyle style, params GUILayoutOption[] options);
public static void LabelField (GUIContent label, params GUILayoutOption[] options);
public static void LabelField (GUIContent label, GUIStyle style, params GUILayoutOption[] options);
public static void LabelField (string label, string label2, params GUILayoutOption[] options);
public static void LabelField (string label, string label2, GUIStyle style, params GUILayoutOption[] options);
public static void LabelField (GUIContent label, GUIContent label2, params GUILayoutOption[] options);
public static void LabelField (GUIContent label, GUIContent label2, GUIStyle style, params GUILayoutOption[] options);
private void OnGUI() { EditorGUILayout.LabelField("Draw Label"); }
EditorGUILayout.LayerField
public static int LayerField (int layer, params GUILayoutOption[] options);
public static int LayerField (int layer, GUIStyle style, params GUILayoutOption[] options);
public static int LayerField (string label, int layer, params GUILayoutOption[] options);
public static int LayerField (string label, int layer, GUIStyle style, params GUILayoutOption[] options);
public static int LayerField (GUIContent label, int layer, params GUILayoutOption[] options);
public static int LayerField (GUIContent label, int layer, GUIStyle style, params GUILayoutOption[] options);
private int _selectedLayer; private void OnGUI() { _selectedLayer = EditorGUILayout.LayerField("Select Layer", _selectedLayer); }
EditorGUILayout.LongField
public static long LongField (long value, params GUILayoutOption[] options);
public static long LongField (long value, GUIStyle style, params GUILayoutOption[] options);
public static long LongField (string label, long value, params GUILayoutOption[] options);
public static long LongField (string label, long value, GUIStyle style, params GUILayoutOption[] options);
public static long LongField (GUIContent label, long value, params GUILayoutOption[] options);
public static long LongField (GUIContent label, long value, GUIStyle style, params GUILayoutOption[] options);
private long _longValue; private void OnGUI() { _longValue = EditorGUILayout.LongField("Long", _longValue); }
EditorGUILayout.MaskField
public static int MaskField (GUIContent label, int mask, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static int MaskField (string label, int mask, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static int MaskField (GUIContent label, int mask, string[] displayedOptions, params GUILayoutOption[] options);
public static int MaskField (string label, int mask, string[] displayedOptions, params GUILayoutOption[] options);
public static int MaskField (int mask, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static int MaskField (int mask, string[] displayedOptions, params GUILayoutOption[] options);
enum を使わず Flags を利用できる
全フラグが立っているときは-1になる
private int _flags; private static string[] Options = new string[] { "Up", "Down", "Left", "Right", }; private void OnGUI() { _flags = EditorGUILayout.MaskField("Mask", _flags, Options); EditorGUILayout.LabelField(_flags.ToString()); }
EditorGUILayout.MinMaxSlider
public static void MinMaxSlider (ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options);
public static void MinMaxSlider (string label, ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options);
public static void MinMaxSlider (GUIContent label, ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options);
private float _floatMinValue; private float _floatMaxValue; private void OnGUI() { EditorGUILayout.LabelField("Min", _floatMinValue.ToString()); EditorGUILayout.LabelField("Max", _floatMaxValue.ToString()); EditorGUILayout.MinMaxSlider("MinMax", ref _floatMinValue, ref _floatMaxValue, 0f, 10f); }
EditorGUILayout.ObjectField
public static Object ObjectField (Object obj, Type objType, bool allowSceneObjects, params GUILayoutOption[] options);
public static Object ObjectField (string label, Object obj, Type objType, bool allowSceneObjects, params GUILayoutOption[] options);
public static Object ObjectField (GUIContent label, Object obj, Type objType, bool allowSceneObjects, params GUILayoutOption[] options);
private GameObject _selectSceneObject; private GameObject _selectObject; private void OnGUI() { _selectSceneObject = (GameObject) EditorGUILayout.ObjectField("GameObject", _selectSceneObject, typeof(GameObject)); _selectObject = (GameObject) EditorGUILayout.ObjectField("GameObject not Scene", _selectObject, typeof(GameObject), false); }
EditorGUILayout.PasswordField
public static string PasswordField (string password, params GUILayoutOption[] options);
public static string PasswordField (string password, GUIStyle style, params GUILayoutOption[] options);
public static string PasswordField (string label, string password, params GUILayoutOption[] options);
public static string PasswordField (string label, string password, GUIStyle style, params GUILayoutOption[] options);
public static string PasswordField (GUIContent label, string password, params GUILayoutOption[] options);
public static string PasswordField (GUIContent label, string password, GUIStyle style, params GUILayoutOption[] options);
private string _password; private void OnGUI() { _password = EditorGUILayout.PasswordField("Password", _password); }
EditorGUILayout.Popup
public static int Popup (int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options);
public static int Popup (int selectedIndex, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static int Popup (int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options);
public static int Popup (int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static int Popup (string label, int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options);
public static int Popup (string label, int selectedIndex, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static int Popup (GUIContent label, int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options);
public static int Popup (GUIContent label, int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
private static readonly string[] Colors = new string[] { "White", "Black", "Gray", "Red", "Green", "Blue", }; private int _selectIndex; private void OnGUI() { _selectIndex = EditorGUILayout.Popup("Select Color", _selectIndex, Colors); }
EditorGUILayout.PrefixLabel
public static void PrefixLabel (string label, GUIStyle followingStyle= "Button");
public static void PrefixLabel (string label, GUIStyle followingStyle, GUIStyle labelStyle);
public static void PrefixLabel (GUIContent label, GUIStyle followingStyle= "Button");
public static void PrefixLabel (GUIContent label, GUIStyle followingStyle, GUIStyle labelStyle);
HorizontalScope
と一緒に利用し、ラベルをクリックすると横のフィールドをアクティブにすることができる
IntField
や FloatField
などはラベルをドラッグすると値を変えれるので利用するには適さない
private int _intValue; private void OnGUI() { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.PrefixLabel("Label"); _intValue = EditorGUILayout.IntField(_intValue); } }
EditorGUILayout.RectField
public static Rect RectField(Rect value, params GUILayoutOption[] options);
public static Rect RectField(string label, Rect value, params GUILayoutOption[] options);
public static Rect RectField(GUIContent label, Rect value, params GUILayoutOption[] options);
private Rect _rect; private void OnGUI() { _rect = EditorGUILayout.RectField("Rect", _rect); }
EditorGUILayout.RectIntField
public static RectInt RectIntField(RectInt value, params GUILayoutOption[] options);
public static RectInt RectIntField(string label, RectInt value, params GUILayoutOption[] options);
public static RectInt RectIntField(GUIContent label, RectInt value, params GUILayoutOption[] options);
private RectInt _rectInt; private void OnGUI() { _rectInt = EditorGUILayout.RectIntField("RectInt", _rectInt); }
EditorGUILayout.SelectableLabel
public static void SelectableLabel (string text, params GUILayoutOption[] options);
public static void SelectableLabel (string text, GUIStyle style, params GUILayoutOption[] options);
選択可能なラベル、部分・全体的にコピーすることができる
private void OnGUI() { EditorGUILayout.SelectableLabel("it's piece of cake"); }
EditorGUILayout.Slider
public static float Slider (float value, float leftValue, float rightValue, params GUILayoutOption[] options);
public static float Slider (string label, float value, float leftValue, float rightValue, params GUILayoutOption[] options);
public static float Slider (GUIContent label, float value, float leftValue, float rightValue, params GUILayoutOption[] options);
private float _floatValue; private void OnGUI() { _floatValue = EditorGUILayout.Slider("Slider", _floatValue, 0f, 1f); }
EditorGUILayout.TagField
public static string TagField (string tag, params GUILayoutOption[] options);
public static string TagField (string tag, GUIStyle style, params GUILayoutOption[] options);
public static string TagField (string label, string tag, params GUILayoutOption[] options);
public static string TagField (string label, string tag, GUIStyle style, params GUILayoutOption[] options);
public static string TagField (GUIContent label, string tag, params GUILayoutOption[] options);
public static string TagField (GUIContent label, string tag, GUIStyle style, params GUILayoutOption[] options);
private string _tag; private void OnGUI() { _tag = EditorGUILayout.TagField("Select Tag", _tag); }
EditorGUILayout.TextArea
public static string TextArea (string text, params GUILayoutOption[] options);
public static string TextArea (string text, GUIStyle style, params GUILayoutOption[] options);
高さが可変なテキストエリア
Enterを押すことで改行できる
private string _text = string.Empty; private void OnGUI() { _text = EditorGUILayout.TextArea(_text); }
EditorGUILayout.TextField
public static string TextField (string text, params GUILayoutOption[] options);
public static string TextField (string text, GUIStyle style, params GUILayoutOption[] options);
public static string TextField (string label, string text, params GUILayoutOption[] options);
public static string TextField (string label, string text, GUIStyle style, params GUILayoutOption[] options);
public static string TextField (GUIContent label, string text, params GUILayoutOption[] options);
public static string TextField (GUIContent label, string text, GUIStyle style, params GUILayoutOption[] options);
private string _text = string.Empty; private void OnGUI() { _text = EditorGUILayout.TextField("Text Field", _text); }
EditorGUILayout.Toggle
public static bool Toggle (bool value, params GUILayoutOption[] options);
public static bool Toggle (string label, bool value, params GUILayoutOption[] options);
public static bool Toggle (GUIContent label, bool value, params GUILayoutOption[] options);
public static bool Toggle (bool value, GUIStyle style, params GUILayoutOption[] options);
public static bool Toggle (string label, bool value, GUIStyle style, params GUILayoutOption[] options);
public static bool Toggle (GUIContent label, bool value, GUIStyle style, params GUILayoutOption[] options);
private bool _toggle; private void OnGUI() { _toggle = EditorGUILayout.Toggle("Toggle", _toggle); }
EditorGUILayout.ToggleLeft
public static bool ToggleLeft (string label, bool value, params GUILayoutOption[] options);
public static bool ToggleLeft (GUIContent label, bool value, params GUILayoutOption[] options);
public static bool ToggleLeft (string label, bool value, GUIStyle labelStyle, params GUILayoutOption[] options);
public static bool ToggleLeft (GUIContent label, bool value, GUIStyle labelStyle, params GUILayoutOption[] options);
private bool _toggle; private void OnGUI() { _toggle = EditorGUILayout.ToggleLeft("Toggle", _toggle); }
EditorGUILayout.Vector2Field
public static Vector2 Vector2Field (string label, Vector2 value, params GUILayoutOption[] options);
public static Vector2 Vector2Field (GUIContent label, Vector2 value, params GUILayoutOption[] options);
private Vector2 _vector2; private void OnGUI() { _vector2 = EditorGUILayout.Vector2Field("Vector2", _vector2); }
EditorGUILayout.Vector2IntField
public static Vector2Int Vector2IntField (string label, Vector2Int value, params GUILayoutOption[] options);
public static Vector2Int Vector2IntField (GUIContent label, Vector2Int value, params GUILayoutOption[] options);
private Vector2Int _vector2Int; private void OnGUI() { _vector2Int = EditorGUILayout.Vector2IntField("Vector2Int", _vector2Int); }
EditorGUILayout.Vector3Field
public static Vector3 Vector3Field (string label, Vector3 value, params GUILayoutOption[] options);
public static Vector3 Vector3Field (GUIContent label, Vector3 value, params GUILayoutOption[] options);
private Vector3 _vector3; private void OnGUI() { _vector3 = EditorGUILayout.Vector3Field("Vector3", _vector3); }
EditorGUILayout.Vector3IntField
public static Vector3Int Vector3IntField (string label, Vector3Int value, params GUILayoutOption[] options);
public static Vector3Int Vector3IntField (GUIContent label, Vector3Int value, params GUILayoutOption[] options);
private Vector3Int _vector3Int; private void OnGUI() { _vector3Int = EditorGUILayout.Vector3IntField("Vector3Int", _vector3Int); }
EditorGUILayout.Vector4Field
public static Vector4 Vector4Field(string label, Vector4 value, params GUILayoutOption[] options);
private Vector4 _vector4; private void OnGUI() { _vector4 = EditorGUILayout.Vector4Field("Vector4", _vector4); }