1 Problem with Inventory!

When you take the time to understand it should be fairly clear…

This is how it is set up:

slot_1
slot_2
slot_3

slot_1
slot_2
slot_3

Which are all clickable buttons, so:

slot_1 // when we click this one it changes color
slot_2 // when we click this one the one above changes back, and this one changes color!
slot_3 // same thing

slot_1
slot_2
slot_3

However…

slot_1 // if we click this it changes color (which is same as before)
slot_2
slot_3

slot_1 // if we click this it changes color and the one above (1st category, 1st slot) does NOT change.
slot_2
slot_3

The problem ONLY occurs when we click the same slot in a different category, otherwise its fine.

Here is the code I wrote that makes all of it happen:

private void DisplaySlots(int X, int Y)
	{	
	 GUILayout.BeginArea(new Rect((Screen.width/1.5f)+45, (Screen.height)/2-30, 180, 500));
		
	 for (int i = X; i < Y; i++) // Display either 1-4 or 5-8 Categories
	 {
	      for (int j = 0; j < 5; j++) // Display five slots for each Category
	      {
	            if (GUILayout.Button(Spells[i][j], SpellSlot[i][j]))
	            {
	                 for (int slot = 0; slot < 5; slot++)
	                 {
		  if (slot == j)
	                      {
		         SpellSlot[i][j].normal.textColor = Color.white;
		  }
		  else
	                      {
		         for (int k = X; k < Y; k++)
		         {
		                 SpellSlot[k][slot].normal.textColor = Color.black;
		         }
		   }
	              }
                         }
                  }
            GUILayout.Space(15); 
         }
			
		GUILayout.EndArea();

It would be so nice to get it fully functional! It is just one minor issue…

Sorry I had a hard time editing my post…how do i delete?

you can always click the “edit post” button… And remove all the tabs when you post your codes, replace them with space…

w/e im over it. if anyone wants to help they can cpy and paste into a text editor.

Probably would work better to keep a couple static vars -

selectedCategory
selectedSlot

And update color based on them.

Something akin to -

if ( button ) {
SpellSlot[ selectedCategory ][ selectedSlot ].normal.textColor = Color.Black;
selectedCategory = i;
selectedSlot = j;
SpellSlot[ selectedCategory ][ selectedSlot ].normal.textColor = Color.White;

funny, I actually tried that. I couldn’t change anything! Because OnGUI is being called so fast.

EDIT: Are you saying total forget about the iteration?

omg that worked!!!~

nm! I really do appreciate the other days post btw…