Bringing GUI.tooltip in front of buttons

I’m trying to make tooltips similar to the ones shown here for the inventory I’m making, but the problem I’m having is the tooltip shows up behind the other buttons. I’ve tried making a separate script for the button with the tooltip and setting different GUI.depths on either script, which works as far as the tooltip being in front goes, but I am unable to find a way to use that button in the inventory script’s GUILayout Area. I’ve also tried using BringWindowToFront but that didn’t work either, although I could just be going about this all wrong and there’s probably a better way to do this.

Here is part of my script.

###Inventory Script

void InventoryWindowMethod (int windowId)
	{	
		
		GUILayout.BeginArea(inventory);
		GUILayout.BeginHorizontal ();
		GUILayout.Button ("Item", GUILayout.Height(64), GUILayout.Width (64));
		if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
		{
			GUI.Box(new Rect(Event.current.mousePosition.x+17, Event.current.mousePosition.y, 100, 20 ), GUI.tooltip);
		}
		GUILayout.Button ("Item", GUILayout.Height(64), GUILayout.Width (64));
		GUILayout.Button ("Item", GUILayout.Height(64), GUILayout.Width (64));
		GUILayout.Button ("Item", GUILayout.Height(64), GUILayout.Width (64));
		GUILayout.Button ("Item", GUILayout.Height(64), GUILayout.Width (64));
		GUILayout.EndHorizontal();
        GUILayout.EndArea();

Let me know if you need more info, and thanks in advance for the help.

Declare a Rect before the area, assign the value to it inside your “if” and finally move the display of tooltip right after EndArea:

Rect rect = new Rect();
GUI.tooltip = "";
GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
GUILayout.BeginHorizontal ();
GUILayout.Button ("Item1", GUILayout.Height(64), GUILayout.Width (64));
if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
	rect = new Rect(Event.current.mousePosition.x+17, Event.current.mousePosition.y, 100, 20 );
	GUI.tooltip = "Item1";
}
GUILayout.Button ("Item2", GUILayout.Height(64), GUILayout.Width (64));
if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
	rect = new Rect(Event.current.mousePosition.x+17, Event.current.mousePosition.y, 100, 20 );
	GUI.tooltip = "Item2";
}
GUILayout.Button ("Item3", GUILayout.Height(64), GUILayout.Width (64));
if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
	rect = new Rect(Event.current.mousePosition.x+17, Event.current.mousePosition.y, 100, 20 );
	GUI.tooltip = "Item3";
}
GUILayout.Button ("Item4", GUILayout.Height(64), GUILayout.Width (64));
if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
	rect = new Rect(Event.current.mousePosition.x+17, Event.current.mousePosition.y, 100, 20 );
	GUI.tooltip = "Item4";
}
GUILayout.Button ("Item5", GUILayout.Height(64), GUILayout.Width (64));
if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
	rect = new Rect(Event.current.mousePosition.x+17, Event.current.mousePosition.y, 100, 20 );
	GUI.tooltip = "Item5";
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
GUI.Box(rect, GUI.tooltip);