Help with Lists and SelectionGrid

Hello, I have two questions to ask about the Lists because I am making an inventory.

  1. I use GUILayout.SelectionGrid, who show a string List. In these List there are my items, like Axe or Sword. So in my list I have “Axe” and “Sword” and the selectionGrid show it very well. But, I also want to translate my game, so Axe and Sword will change if the game is in Italian or French per example. The problem is I can’t directly do it in the list because the string will change, it is possible to, if in the list the item is “Axe”, in the inventory grid it would be item.axe (per example)?

  2. I also want to add the number of an item, it would be perfect if I can do like that: item.axe + “(” + axeNumber.ToString() + “)”.

Cordialy.

My code:

public List<string> InventoryItemName = new List<string>();

in OnGUI ():

customerGridNames = new string[InventoryItemName.Count];
    				for(int cnt = 0; cnt < InventoryItemName.Count; cnt++) {
    					customerGridNames[cnt] = InventoryItemName[cnt];
    				}

scrollPos = GUILayout.BeginScrollView (scrollPos);
selectedGrid = GUILayout.SelectionGrid(selectedGrid, customerGridNames, 1);
				if (selectedGrid == item.axeID) mainID = item.axeID;
				if (selectedGrid == item.swordID) mainID = item.swordID;
GUILayout.EndScrollView ();

I recommend you to store an ID for each item in the list instead of store their names, because the name is not the identifier but a property. Make a mini database (an array an other list a txt file) to store an item’s properties.

For example:

0;Axe;30;0;5

It means:

Id - 0

Name - Axe

Attack damage - 30

Magic damage - 0

Attack speed - 5

Store only the ID, here the “0” in the grid and if you want to rename the thing you can do it easily.

For your second question, I recommend you to make a list to store the “currentItems”. It can be something like that:
0;3;1 – the item with ID 0 count of 3 on the 1th pleace… Figure it out.

I hope it helped let me know if you have any more problems!