|
Hi all! Here i go! I got a inventory array where i put my item name in it once they've been picked up! Then i want to create a button for each items listed in this array with a for each loops. Problem is the loop is working but it put all the content of the inventory in one button! How can i create a button for each item. I've also tried with a regular for loop. So anyway here my code :
(comments are locked)
|
|
You just gave us a small piece of your code. We don't know what's inside your inventory enumeration. I just guess it's a string. In that case it should look like that:
For such loop-created buttons it's much easier to use GUILayout: Bunny83 Thank for the reply it's exactly what i was looking for!!! Works greats!!!
Apr 29 '11 at 06:11 PM
calyston000
(comments are locked)
|
Like "xCRKx TyPHooN" you're showing the same content on every button and i guess what ever is inside the inventory array/enumeration is not an integer that can be used as offset.
Apr 29 '11 at 05:36 PM
Bunny83
(comments are locked)
|
|
The GUI Button will be spawning on top of one another, you should increment one of the rect variables to move the box as you place your inventory. Example:
This will stack the gui boxes on top of one another. Well, your example is written in C# the OP uses JS. The offset thing is right but you place them offscreen. I think you want to use "+= 30". Besides that inventory seems to be an enumeration so the button context should be "i" and not "InventoryManager.inventory"
Apr 29 '11 at 05:34 PM
Bunny83
(comments are locked)
|
|
All your buttons have the same position ?
(comments are locked)
|
|
I've tried both codes and it's doing the same thing both! It's creating only one button with all the inventory in it! Also just for the record, the array inventory is an array that i've declared just like that : inventory = new Array (); //declaring the inventory What i'm not understanding both of the code up there should works and I tougth the same that it was the offset the problem!! But it's it's creating only one instance of the buttons! By the thanks ya all for the help! I'm giving you all the sample of the code here : InventoryManager
Pickup Script
GuiInventory
Hope it can help ya!
(comments are locked)
|
1 2 next page »
