- Home /
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"))
{
}
}
Comment
Answer by BlackHoleStudio · Apr 08, 2016 at 01:56 PM
This is what I used:
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:
menu.jpg
(22.6 kB)
screen.jpg
(171.6 kB)