//Setting up the Inventory window
void DisplayInventoryWindow(int windowID)
{
GUI.Label (new Rect (0, 0, 840, 40), “Ekwipunek”, “LabelWindow”);
GUI.BeginGroup (new Rect (0, 0, 840, 100));
GUI.skin = buttonSkin;
if(GUI.Button (new Rect (320, 50, 100, 35), "Postać"))
{
ui.ShowMain = true;
ui.ShowCraft = false;
ui.ShowInv = false;
}
if(GUI.Button (new Rect (430, 50, 100, 35), "Wytwarzanie"))
{
ui.ShowMain = false;
ui.ShowInv = false;
ui.ShowCraft = true;
}
GUI.EndGroup ();
GUI.skin = cSheetSkin;
GUI.BeginGroup (new Rect (30, 117, 380, 280));
GUI.Box (new Rect (0, 0, 380, 280), "");
int index = 0;
foreach(Item a in cSheet.ArmorSlot) //Loop through the ArmorSlot array.
{
if(a == null)
{
if(GUI.Button(cSheet.buttonPositions[index], cSheet.ArmorSlotName[index])) //If we click this button (that has no item equipped):
{
InventoryDisplay id = GetComponent<InventoryDisplay>();
if(id.itemBeingDragged != null) //If we are dragging an item:
{
cSheet.EquipItem(id.itemBeingDragged,index); //Equip the Item.
id.ClearDraggedItem();//Stop dragging the item.
}
}
}
else
{
if(GUI.Button(cSheet.buttonPositions[index],cSheet.ArmorSlot[index].itemIcon)) //If we click this button (that has an item equipped):
{
InventoryDisplay id2 = GetComponent<InventoryDisplay>();
if(id2.itemBeingDragged != null) //If we are dragging an item:
{
cSheet.EquipItem(id2.itemBeingDragged,index); //Equip the Item.
id2.ClearDraggedItem(); //Stop dragging the item.
}
else if (cSheet.playersinv.Contents.Count < cSheet.playersinv.MaxContent) //If there is room in the inventory:
{
cSheet.UnequipItem(cSheet.ArmorSlot[index]); //Unequip the Item.
cSheet.ArmorSlot[index] = null; //Clear the slot.
id2.ClearDraggedItem(); //Stop dragging the Item.
}
else if (cSheet.DebugMode)
{
Debug.Log("Could not unequip " + cSheet.ArmorSlot[index].name + " since the inventory is full");
}
}
}
index++;
}
GUI.EndGroup ();
GUI.skin = invSkin;
GUI.BeginGroup (new Rect (30, 117, 380, 280));
GUI.Box (new Rect (440, 117, 370, 280), "");
/*
if (canBeDragged == true)
{
GUI.DragWindow (new Rect (0,0, 10000, 30)); //the window to be able to be dragged
}
*/
var currentX = 0 + Offset.x; //Where to put the first items.
var currentY = 18 + Offset.y; //Im setting the start y position to 18 to give room for the title bar on the window.
foreach(Transform i in UpdatedList.ToArray()) //Start a loop for whats in our list.
{
Item item = i.GetComponent<Item>();
if (cSheetFound) //CSheet was found (recommended)
{
if(GUI.Button(new Rect(currentX,currentY,itemIconSize.x,itemIconSize.y),item.itemIcon))
{
var dragitem=true; //Incase we stop dragging an item we dont want to redrag a new one.
if(itemBeingDragged == item) //We clicked the item, then clicked it again
{
if (cSheetFound)
{
GetComponent<Character>().UseItem(item,0,true); //We use the item.
}
ClearDraggedItem(); //Stop dragging
dragitem = false; //Dont redrag
}
if (Event.current.button == 0) //Check to see if it was a left click
{
if(dragitem)
{
if (item.isEquipment == true) //If it's equipment
{
Debug.Log("Podniosłem itema");
itemBeingDragged = item; //Set the item being dragged.
draggedItemSize=itemIconSize; //We set the dragged icon size to our item button size.
//We set the position:
draggedItemPosition.y=Screen.height-Input.mousePosition.y-15;
draggedItemPosition.x=Input.mousePosition.x+15;
}
if(item.isUsable)
{
i.GetComponent<ItemEffect>().UseEffect(); //It's not equipment so we just use the effect.
}
}
}
if (Event.current.button == 1) //If it was a right click we want to drop the item.
{
associatedInventory.DropItem(item);
}
}
}
else //No CSheet was found (not recommended)
{
if(GUI.Button(new Rect(currentX,currentY,itemIconSize.x,itemIconSize.y),item.itemIcon))
{
if (Event.current.button == 0 && item.isEquipment != true) //Check to see if it was a left click.
{
i.GetComponent<ItemEffect>().UseEffect(); //Use the effect of the item.
}
if (Event.current.button == 1) //If it was a right click we want to drop the item.
{
associatedInventory.DropItem(item);
}
}
}
if(item.stackable) //If the item can be stacked:
{
GUI.Label(new Rect(currentX, currentY, itemIconSize.x, itemIconSize.y), "" + item.stack, "Stacks"); //Showing the number (if stacked).
}
currentX += itemIconSize.x;
if(currentX + itemIconSize.x + Offset.x > windowSize.x) //Make new row
{
currentX=Offset.x; //Move it back to its startpoint wich is 0 + offsetX.
currentY+=itemIconSize.y; //Move it down a row.
if(currentY + itemIconSize.y + Offset.y > windowSize.y) //If there are no more room for rows we exit the loop.
{
return;
}
}
}
GUI.EndGroup ();
}
And i have this error:
GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)
appears when i add last GUI.BeginGroup();, after GUI.skin = invSkin;
Can you help me with this ?