- Home /
Stackable Inventory Item
I did a quick search on google/unityanswers and found nothing so I figured I'd post it here. I have an inventory mostly working now, but if I wanted a certain object to be able to hold more than 1 per slot, what would I need to do? Thanks. Oh, and if you are to do some code, JS would be preferable.
We have no idea how your system works so how should we "extend" yours? There are millions of ways to create an inventory system, so can you go a bit more in detail? $$anonymous$$aybe add some of your code you already have? You can edit your question at any time.
Ah yes sorry, I was just looking for a general answer I suppose, but I do realize it limits the resulting answers, and will add some code next time if I have troubles with @Justin Warner 's suggestion.
Answer by Justin Warner · Apr 01, 2011 at 02:01 AM
When you pick up an object you already have one of... Just increment the "amount of," and change the graphics to "multiple __"... Just keep it as a static variable...
Example, apple.
Player inventories an apple. apple++. Change graphic of apple to apples. Then on hover, add a tooltip so that it shows "Apples "+ apple (apply being the amount of apples var).
Does this make sense?
Yes actually, and how hard would it be to add the number of apples to the graphic rather than having to hover over it?
Sorry never $$anonymous$$d, I figured that much out, leave the easy part to me eh? I just did a GUI.Label and put the variable as the string and output it down and to the right of where my inventory draws the item and it works.
Alright, hey again Justin. I was wondering if you knew a way around this. I got the stack thing working just fine, however, the way I programmed it, it can only have a single stack of a single item, (example: 50 gold) when I want to have multiple stacks of a single item (example: 5 stacks of 50 gold). Would you know a way around this?
Actually, never$$anonymous$$d. I don't see the point in limiting people on the things I wish to make stackable, I'm not a hater like that. I'll just set a high limit & make it so there can only be one stack:)
Your answer
Follow this Question
Related Questions
Help making premade Items for farming game 2 Answers
Problem with dropping items from my inventory 0 Answers
A question about creating items using scriptable objects 1 Answer
Managing Item Types 1 Answer