How to make a GUI.Button open/close a GUI.Box?

For my game, it would come in handy if I had a button which would show another box when it is clicked, and when it is clicked again, the box would close. If I knew how to do this it could allow me to do an inventory/overview like system for my ships (space sim), and I could have other features.

I’ve tried some codes with no luck, so how would I go about doing this? Any help would be appreciated, thanks!

This is somewhat basic code but here you go:

// javascript

var isBoxShowing : boolean;

function OnGUI()
{
	if (GUI.Button(Rect(60, 20, 100, 50), "Open Window"))
	{
		isBoxShowing = !isBoxShowing;
	}
	
	if(isBoxShowing)
	{
		GUI.Box(Rect(200, 20, 100, 50), "");
	}
}