I have another problem with my code that I can't fix :\
Basically i have an enum called 'type' in my Item class, which tells me if the item is consumable, or equipment, etc. In the database script I have made, it sets the type for each item (5 in total). So basically I have an inventory UI, with 5 items (inc. 2x consumables, 3x Equip)
After much debugging/checking things, I've found that the boolean prior to "sortedItems.Add(i);" is always FALSE. But it shouldnt be, BOTH VALUES ARE THE SAME as per the console log. I have input a print() line to check whats going on because my items are'nt sorting by type when I expect them to.
public void SortItemsByType(string type)
{
sortedItems.Clear();
foreach (Item i in allItems)
{
print("is the following true or false" + i.type.ToString() == type);
print("this is iToString= " + i.type.ToString());
print("and this is type: " + type);
if (i.type.ToString() == type)
sortedItems.Add(i);
}
}
and (please note the 3 print lines, here is their output in the console: (sorry but the dumb IDE won't let me copy-paste the console, here is image):
Im still very much a noob to this, so I am sure there is something I have missed. But for the life of me i cannot figure out why that bool is always resulting in FALSE?
Any help is massively appreciated. Thanks