Version: 2022.2
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);

参数

label 字段的前缀标签。
mask 要显示的当前掩码。
displayedOption 包含每个标志的标签的字符串数组。
options 一个可选的布局选项列表,用于指定额外的布局属性。此处传递的任何值都将覆盖 style 定义的设置。
另请参阅:GUILayout.WidthGUILayout.HeightGUILayout.MinWidthGUILayout.MaxWidthGUILayout.MinHeightGUILayout.MaxHeightGUILayout.ExpandWidthGUILayout.ExpandHeight

返回

int 用户修改的值。

描述

创建一个适用于掩码的字段。


显示掩码字段的简单窗口。

using UnityEngine;
using UnityEditor;

public class MaskFieldExample : EditorWindow { static int flags = 0; static string[] options = new string[] {"CanJump", "CanShoot", "CanSwim"};

[MenuItem("Examples/Mask Field usage")] static void Init() { MaskFieldExample window = (MaskFieldExample)GetWindow(typeof(MaskFieldExample)); window.Show(); }

void OnGUI() { flags = EditorGUILayout.MaskField("Player Flags", flags, options); } }