- Home /
button wont work in GUI.BeginScrollView
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
Follow this Question
Related Questions
Click on a button that is created post start. 0 Answers
change the style of a gui by a key press 0 Answers
How do I use my .png file as a button? 1 Answer
New GUI and Inventory problem. 1 Answer
Scrolling Inventory Overview Technique 0 Answers