# BoundsField

> Makes Center and Extents field for entering a Bounds.

## Definition

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

## BoundsField(Rect, Bounds)

Makes Center and Extents field for entering a [Bounds](/engine/6000.7/script-reference/unityengine/bounds.md).

```csharp
public static Bounds BoundsField(Rect position, Bounds value)
```

### Parameters

**** (\[Rect]\(/engine/6000.7/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[Bounds]\(/engine/6000.7/script-reference/unityengine/bounds)): The value to edit.

### Returns

| Type                                                            | Description                    |
| --------------------------------------------------------------- | ------------------------------ |
| [Bounds](/engine/6000.7/script-reference/unityengine/bounds.md) | The value entered by the user. |

### Remarks

![EditorGUIBoundsField (BoundsField)](/api/media?file=/engine/6000.7/media/images/EditorGUIBoundsField.png)

*Bounds field in an Editor Window.*

See also  [Extending the editor](/engine/6000.7/manual/extending-the-editor.md).

### Examples

```csharp
using UnityEngine;
using UnityEditor;


// Simple script that shows radius of bounds of selected MeshFilter

class EditorGUILayoutBoundsField : EditorWindow
{
    float radius = 0;
    Bounds bounds;

    [MenuItem("Examples/Show Radius of mesh bounds")]
    static void Init()
    {
        var window = GetWindow<EditorGUILayoutBoundsField>();
        window.Show();
    }

    void OnGUI()
    {
        GUILayout.Label("Select a mesh in the Hierarchy view and click 'Capture Bounds'");
        EditorGUILayout.BeginHorizontal();
        bounds = EditorGUILayout.BoundsField("Mesh bounds:", bounds);

        if (GUILayout.Button("Capture Bounds") && Selection.activeTransform)
        {
            MeshFilter meshFilter = Selection.activeTransform.GetComponentInChildren<MeshFilter>();
            if (meshFilter)
            {
                bounds = meshFilter.sharedMesh.bounds;
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Radius:", bounds.size.magnitude.ToString());
        if (GUILayout.Button("Close"))
        {
            this.Close();
        }
    }
}
```

## BoundsField(Rect, string, Bounds)

Makes Center and Extents field for entering a [Bounds](/engine/6000.7/script-reference/unityengine/bounds.md).

```csharp
public static Bounds BoundsField(Rect position, string label, Bounds value)
```

### Parameters

**** (\[Rect]\(/engine/6000.7/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label to display above the field.**** (\[Bounds]\(/engine/6000.7/script-reference/unityengine/bounds)): The value to edit.

### Returns

| Type                                                            | Description                    |
| --------------------------------------------------------------- | ------------------------------ |
| [Bounds](/engine/6000.7/script-reference/unityengine/bounds.md) | The value entered by the user. |

### Remarks

![EditorGUIBoundsField (BoundsField)](/api/media?file=/engine/6000.7/media/images/EditorGUIBoundsField.png)

*Bounds field in an Editor Window.*

See also  [Extending the editor](/engine/6000.7/manual/extending-the-editor.md).

### Examples

```csharp
using UnityEngine;
using UnityEditor;


// Simple script that shows radius of bounds of selected MeshFilter

class EditorGUILayoutBoundsField : EditorWindow
{
    float radius = 0;
    Bounds bounds;

    [MenuItem("Examples/Show Radius of mesh bounds")]
    static void Init()
    {
        var window = GetWindow<EditorGUILayoutBoundsField>();
        window.Show();
    }

    void OnGUI()
    {
        GUILayout.Label("Select a mesh in the Hierarchy view and click 'Capture Bounds'");
        EditorGUILayout.BeginHorizontal();
        bounds = EditorGUILayout.BoundsField("Mesh bounds:", bounds);

        if (GUILayout.Button("Capture Bounds") && Selection.activeTransform)
        {
            MeshFilter meshFilter = Selection.activeTransform.GetComponentInChildren<MeshFilter>();
            if (meshFilter)
            {
                bounds = meshFilter.sharedMesh.bounds;
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Radius:", bounds.size.magnitude.ToString());
        if (GUILayout.Button("Close"))
        {
            this.Close();
        }
    }
}
```

## BoundsField(Rect, GUIContent, Bounds)

Makes Center and Extents field for entering a [Bounds](/engine/6000.7/script-reference/unityengine/bounds.md).

```csharp
public static Bounds BoundsField(Rect position, GUIContent label, Bounds value)
```

### Parameters

**** (\[Rect]\(/engine/6000.7/script-reference/unityengine/rect)): Rectangle on the screen to use for the field.**** (\[GUIContent]\(/engine/6000.7/script-reference/unityengine/guicontent)): Optional label to display above the field.**** (\[Bounds]\(/engine/6000.7/script-reference/unityengine/bounds)): The value to edit.

### Returns

| Type                                                            | Description                    |
| --------------------------------------------------------------- | ------------------------------ |
| [Bounds](/engine/6000.7/script-reference/unityengine/bounds.md) | The value entered by the user. |

### Remarks

![EditorGUIBoundsField (BoundsField)](/api/media?file=/engine/6000.7/media/images/EditorGUIBoundsField.png)

*Bounds field in an Editor Window.*

See also  [Extending the editor](/engine/6000.7/manual/extending-the-editor.md).

### Examples

```csharp
using UnityEngine;
using UnityEditor;


// Simple script that shows radius of bounds of selected MeshFilter

class EditorGUILayoutBoundsField : EditorWindow
{
    float radius = 0;
    Bounds bounds;

    [MenuItem("Examples/Show Radius of mesh bounds")]
    static void Init()
    {
        var window = GetWindow<EditorGUILayoutBoundsField>();
        window.Show();
    }

    void OnGUI()
    {
        GUILayout.Label("Select a mesh in the Hierarchy view and click 'Capture Bounds'");
        EditorGUILayout.BeginHorizontal();
        bounds = EditorGUILayout.BoundsField("Mesh bounds:", bounds);

        if (GUILayout.Button("Capture Bounds") && Selection.activeTransform)
        {
            MeshFilter meshFilter = Selection.activeTransform.GetComponentInChildren<MeshFilter>();
            if (meshFilter)
            {
                bounds = meshFilter.sharedMesh.bounds;
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Radius:", bounds.size.magnitude.ToString());
        if (GUILayout.Button("Close"))
        {
            this.Close();
        }
    }
}
```
