I have an inventory script that contains multiple types of item classes, for example Weapon, Ammo, or Armor and I'm trying to iterate through the inventory and discover what type of class is currently being iterated through:
class Weapon
{
var Icon : Texture;
var Name : String;
var AmmoLoaded : String;
}
class Ammo
{
var Icon : Texture;
var Name : String;
var Quantity : int;
}
function OnGUI()
{
for( var i = 0; i < inventory.length; i ++ in inventory )
{
var currentItem = inventory*;*
*if (currentItem == Weapon) GUILabel( Rect(0,0,20,20), currentItem.Name);*
*if (currentItem == Ammo) GUILabel( Rect(50,0,20,20), currentItem.Name);*
*}*
*}*
*```*
*<p>Here I'm trying to get each type of item to appear in a different place on the screen, but even if I print(currentItem) and it prints out "Weapon" or "Ammo" in the console, it doesn't understand if (currentItem == Weapon).</p>*