# MaskField

> Makes a field for masks.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.6/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

## MaskField(Rect, GUIContent, int, string\[], GUIStyle)

Makes a field for masks.

```csharp
public static int MaskField(Rect position, GUIContent label, int mask, string[] displayedOptions, GUIStyle style)
```

### Parameters

**** (\[Rect]\(/engine/6000.6/script-reference/unityengine/rect)): Rectangle on the screen to use for this control.**** (\[GUIContent]\(/engine/6000.6/script-reference/unityengine/guicontent)): Label for the field.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The current mask to display.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): A string array containing the labels for each flag.**** (\[GUIStyle]\(/engine/6000.6/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.6/script-reference/unityengine/guistyle.md).

### Returns

| Type                                                       | Description                     |
| ---------------------------------------------------------- | ------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The value modified by the user. |

### Remarks

**Note:** The mask values for the flags associated with each option in the menu will be consecutive powers of 2 starting with 1, i.e. 1, 2, 4, 8, 16, and so on.

![MaskField (MaskField)](/api/media?file=/engine/6000.6/media/images/MaskField.png)

*Simple window that shows the mask field.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

class SimpleMaskUsage : EditorWindow
{
    int flags = 0;
    string[] options = { "CanJump", "CanShoot", "CanSwim" };

    [MenuItem("Examples/Mask Field Usage")]
    static void Init()
    {
        var window = GetWindow<SimpleMaskUsage>();
        window.Show();
    }

    void OnGUI()
    {
        flags = EditorGUI.MaskField(new Rect(0, 0, 300, 20), "Player Flags", flags, options);
    }
}
```

## MaskField(Rect, string, int, string\[], GUIStyle)

Makes a field for masks.

```csharp
public static int MaskField(Rect position, string label, int mask, string[] displayedOptions, GUIStyle style)
```

### Parameters

**** (\[Rect]\(/engine/6000.6/script-reference/unityengine/rect)): Rectangle on the screen to use for this control.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Label for the field.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The current mask to display.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): A string array containing the labels for each flag.**** (\[GUIStyle]\(/engine/6000.6/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.6/script-reference/unityengine/guistyle.md).

### Returns

| Type                                                       | Description                     |
| ---------------------------------------------------------- | ------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The value modified by the user. |

### Remarks

**Note:** The mask values for the flags associated with each option in the menu will be consecutive powers of 2 starting with 1, i.e. 1, 2, 4, 8, 16, and so on.

![MaskField (MaskField)](/api/media?file=/engine/6000.6/media/images/MaskField.png)

*Simple window that shows the mask field.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

class SimpleMaskUsage : EditorWindow
{
    int flags = 0;
    string[] options = { "CanJump", "CanShoot", "CanSwim" };

    [MenuItem("Examples/Mask Field Usage")]
    static void Init()
    {
        var window = GetWindow<SimpleMaskUsage>();
        window.Show();
    }

    void OnGUI()
    {
        flags = EditorGUI.MaskField(new Rect(0, 0, 300, 20), "Player Flags", flags, options);
    }
}
```

## MaskField(Rect, int, string\[], GUIStyle)

Makes a field for masks.

```csharp
public static int MaskField(Rect position, int mask, string[] displayedOptions, GUIStyle style)
```

### Parameters

**** (\[Rect]\(/engine/6000.6/script-reference/unityengine/rect)): Rectangle on the screen to use for this control.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The current mask to display.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): A string array containing the labels for each flag.**** (\[GUIStyle]\(/engine/6000.6/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.6/script-reference/unityengine/guistyle.md).

### Returns

| Type                                                       | Description                     |
| ---------------------------------------------------------- | ------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The value modified by the user. |

### Remarks

**Note:** The mask values for the flags associated with each option in the menu will be consecutive powers of 2 starting with 1, i.e. 1, 2, 4, 8, 16, and so on.

![MaskField (MaskField)](/api/media?file=/engine/6000.6/media/images/MaskField.png)

*Simple window that shows the mask field.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

class SimpleMaskUsage : EditorWindow
{
    int flags = 0;
    string[] options = { "CanJump", "CanShoot", "CanSwim" };

    [MenuItem("Examples/Mask Field Usage")]
    static void Init()
    {
        var window = GetWindow<SimpleMaskUsage>();
        window.Show();
    }

    void OnGUI()
    {
        flags = EditorGUI.MaskField(new Rect(0, 0, 300, 20), "Player Flags", flags, options);
    }
}
```
