x


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");
     }
     
 }
more ▼

asked Mar 26, 2012 at 10:18 PM

Kag359six gravatar image

Kag359six
102 83 63 65

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5894
x1369
x619
x470
x137

asked: Mar 26, 2012 at 10:18 PM

Seen: 942 times

Last Updated: Mar 26, 2012 at 10:18 PM