I am making an inventory and i dont understand why i cant do this. Item is a different script with all the variables in it such as: itemName, itemDescription, ect. So why cant i add an new Item? it tells me that i can add a script this way. But im not trying to add the script, im just trying to fill it with the type script.
public Item[ , ] inventory; **Item is a different Script with all the item variables**
void Start ()
{
inventory = new Item[across, down];
for (int x=0; x<5; x++)
{
AddItem(new Item());
}
}
void AddItem (Item item)
{
for (int x=0; x<across; x++)
{
for (int y=0; y<down; y++)
{
if (inventory[x, y] == null)
{
inventory[x, y] = item;
return;
}
if (inventory[x, y].itemName == item.itemName)
{
inventory[x, y].itemAmount += item.itemAmount;
}
}
}
}