- Home /
Question by
Kag359six · Mar 27, 2012 at 07:58 PM ·
guibuttoninventorybeginscrollview
Button in GUI BeginScrollView problem
I just edited my inventory script to use the beginScrollView function. However my button to open the sub menu no longer works in it. Any ideas why? Go under assumption that all variables are defined. code:
function OnGUI() {
numberOfItems = 0;
buttonPosX = 10;
buttonPosY = 25;
if(openInventory == true)
{
if(openSubMenu == true)
{
SubMenu();
}
//begin scroll view
scrollVector = GUI.BeginScrollView(Rect(0, 0, Screen.width/2,
Screen.height/2),scrollVector, Rect(0, 0, 450, 450));
//put stuff in scroll view
GUI.TextArea(Rect(0,0,450,450), "INVENTORY");
for(items in menuItems)
{
if(GUI.Button(Rect(buttonPosX, buttonPosY, 100, 50), items))
{
openSubMenu = true;
currentItem = items;
}
buttonPosX = buttonPosX + 125;
numberOfItems += 1;
if(numberOfItems %4 == 0)
{
buttonPosX = 10;
buttonPosY = buttonPosY + 115;
}
}
GUI.EndScrollView();
//GUI.Box(Rect(0, 0, Screen.width/2, Screen.height/2),"INVENTORY");
}
if(activateIW == true)
{
GUI.Box(Rect(Screen.width - 225, 10, 215,25), "object is already in your inventory");
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613065615im_/https://answers.unity.com/themes/thub/images/avi.jpg)