GUILayoutUtility.GetLastRect Manual     Reference     Scripting  
Scripting > Runtime Classes > GUILayoutUtility
GUILayoutUtility.GetLastRect

static function GetLastRect () : Rect

Returns

Rect - The last used rectangle.

Description

Get the rectangle last used by GUILayout for a control.

// JavaScript example:
function OnGUI()
{
GUILayout.Button( "My button" );
if( GUILayoutUtility.GetLastRect().Contains( Event.current.mousePosition ) )
{
GUILayout.Label( "Mouse over!" );
}
else
{
GUILayout.Label( "Mouse somewhere else" );
}
}

// C# example:
using UnityEngine;
public class GetLastRectExample : MonoBehaviour
{
void OnGUI()
{
GUILayout.Button( "My button" );
if( GUILayoutUtility.GetLastRect().Contains( Event.current.mousePosition ) )
{
GUILayout.Label( "Mouse over!" );
}
else
{
GUILayout.Label( "Mouse somewhere else" );
}
}
}