# GetLastRect()

> Get the rectangle last used by GUILayout for a control.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.IMGUIModule

```csharp
public static Rect GetLastRect()
```

### Returns

| Type                                                        | Description              |
| ----------------------------------------------------------- | ------------------------ |
| [Rect](/engine/6000.5/script-reference/unityengine/rect.md) | The last used rectangle. |

### Remarks

Note that this only works during the Repaint event.

### Examples

```csharp
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    void OnGUI()
    {
        GUILayout.Button("My button");
        if (Event.current.type == EventType.Repaint &&
            GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
        {
            GUILayout.Label("Mouse over!");
        }
        else
        {
            GUILayout.Label("Mouse somewhere else");
        }
    }
}
```
