Author Topic: Inventory list with tabs and text?  (Read 2409 times)

GD.Darren

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Inventory list with tabs and text?
« on: June 12, 2013, 06:02:25 PM »
Hi, I'd like to know the way to implement this.

I would like an inventory system which will have 3 tabs ( 3 item types ) and when you click a specific tab, the proper list is shown with the items the player is holding currently.

I have a List of type Item which I created and its populated dynamically, (number of items can be different). What I'd like to do is create the GUI window of the inventory in a way that when I choose a specific tab ( for example weapons ), a list under the tab is populated at run time with the items of type weapon and I would only like to show the weapons name in the list, however I'd like to also save the ID of that weapon as a reference in that list ( but not visible to the player ) so I can select the item in that list and drop the weapon for example, or equip it and I can than use that ID in order to access my List of items and deal with them in the array too.

My main problem is understanding how to setup the GUI part, and how to only show the name in the list but also save an ID of the item as reference in the same row. I can understand how to sync between the list and array once I set up the GUI correctly because coding wise I'm quite experienced, just need help with how to properly setup the GUI.

Thanks in advance.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Inventory list with tabs and text?
« Reply #1 on: June 13, 2013, 04:05:39 AM »
When you want to hide something like that, create a script that you will attach to the item. On that script create public fields that you can set in inspector, like so:

  1. public class MyItemData : MonoBehaviour
  2. {
  3.     public int id = 0;
  4. }