hi!
i have started working on a inventory system (c#).
every slot in the inventory is a GUI.Button.
now i want to draw a GUI.DrawTexture on every Button with an image of the Item that is in that slot.
at the beginning all slots are empty (ItemInSlot1 = 0;).
i have a function called PickUpItem(); that looks for a free slot and changes the ItemInSlot variable to the number that is representing the item.
but i need to make PickUpItem() to change the texture of the GUI.DrawTexture of SlotToTransferPickUp
in to the texture that is representing the item (ItemToPickUp)
first problem:
how can i check which texture to set for the SlotToTransferPick without hundreds line of code for each item/slot?
example:
if (ItemToPickUp == 1){
if (SlotToTransferPickUp == 1){ItemIconSlot1 = InventoryIconHammer;}
}
second problem:
when i remove the // from this line, the whole inventory is not showing up in game:
//GUI.DrawTexture(new Rect(0,0,64,64), ItemIconSlot1);
just search for "first problem"/"second problem in the script:
[http://pastebin.com/qbw9yPaW][1]
[1]: http://pastebin.com/qbw9yPaW
/edit:
PickUpItem2() should be like this, because i have already reset ItemToPickUp:
if (SlotToTransferPickUp == 1){
if (ItemInSlot1 == 1){
ItemIconSlot1 = InventoryIconHammer;}
}
↧