Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetLastRect()

Get the rectangle last used by GUILayout for a control.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.IMGUIModule
public static Rect GetLastRect()

Returns

Type

Description

RectThe last used rectangle.

Remarks

Note that this only works during the Repaint event.

Examples

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"); } }}