Sub menu not popping up

After an inventory button is clicked, i want a submenu to pop up (function submenu()).
function OnGUI() {

	buttonPosX = 10;
    
    buttonPosY = 10;
	
	if(openInventory == true)
	{
		
		GUI.Box(Rect(0, 0, Screen.width/2, Screen.height/2),"INVENTORY");
		
		for(items in menuItems)
		{
			if(GUI.Button(Rect(buttonPosX, buttonPosY, 100, 50), items))
			{
				subMenu();
			}
			
			buttonPosX = buttonPosX + 125;
		}
	}
	
}

function CurrentInventoryState()
{
	if(Input.GetKeyDown("r"))
	{
		inventoryState += 1;
		
		if(inventoryState > 1)
		{
			inventoryState = 0;
		}
	}
	
	if(inventoryState == 1)
	{
		openInventory = true;
	}
	else
	{
		openInventory = false;
	}
}

function subMenu() {

	GUI.Box(Rect(Screen.height - (Screen.height/2),
	Screen.width - (Screen.width/2), 250,250), "what do you want to do?");

	if(GUI.Button(Rect(Screen.height - (Screen.height/2) -50,
	Screen.width - (Screen.width/2) -50, 50, 50), "Drop"))
	{
	
	}

	if(GUI.Button(Rect(Screen.height - (Screen.height/2) +50,
	Screen.width - (Screen.width/2) +50, 50, 50), "Use"))
	{
	
	}

}

1 Answer

1

This is what I used:
67595-menu.jpg

Clicking on the Options Button opened the Options Menu, but you have to make sure it is enabled in the Inspector by using the OnClick function:

67597-screen.jpg