Displayed are 2 Categories each with 5 slots. I am able to Click slots and change there color in this fassion:
1st Slot <--Click and it changes from black (initial state) to white
2nd Slot <--Click and the above changes back to black, and this one changes white
3rd Slot
//...
It happens correctly for when I just display 1-5 slots for one category. But if I need to display two categories, each with 5 slots, something goes wrong:
1st Slot <--Click and changes from black to white
2nd Slot
3rd Slot
//.... GUILayout.Space(15) give us this space between slot categories
1st Slot <-- Changes from black to white w/o being clicked!
2nd Slot
3rd Slot
so on and so forth, in that way..thus the weiredness is revealed..I don't know how to fix it!! Please help?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
void OnGUI() // Method similar to Update, its for all the GUI fuss.
{
DisplaySlots();
}
void DisplaySlots()
{
GUILayout.BeginArea(new Rect((Screen.width/1.5f)+45, (Screen.height)/2-60, 180, 500));
for (int i = 0; i < 2; i++) // Give the number of SlotCategories to contain 5 slots
{
for (int j = 0; j < 5; j++) // Give the number of actual Slots (5)
{
if (GUILayout.Button(Slots[i][j], SlotCategory[i][j])) // Display Slots
{
// If we clicked an individual slot, we are here!
for (int slot = 0; slot < 5; slot++)
{
if (slot == j) // which slot did we click?
{
SlotCategory[i][j].normal.textColor = Color.white;
}
else
{
SlotCategory[i][slot].normal.textColor = Color.black;
}
}
}
}
GUILayout.Space(15);
}
GUILayout.EndArea();
}
| |
The only thing that I keep telling myself is "keep in <i>this</i> 'i'! I coded this completely myself and just cannot seem to figure it out from here! <CRIES>