I've got here an inventory SO script, which has an InventoryItem as the type for it's container. I have created three versions of this inventory as SOs in the editor.
The inventoryItem is meant to be an 'inventory slot', holding the item and the quantity. Shown at the bottom of the hastebin link.
But the issue I have is that if I want to create a new InventorySlot, I can't then get the item of that slot because those are held in the abstract classes.
if (!isFound)
{
inventoryContainer.Add(new InventoryItem(item, quantity));
InformAboutChange();
}
``` I get an error here.
I understand that you cannot create instances of abstract classes, but id' like it so that the item passed in can be any of these two types and it still work, and then in other scripts if I want to get that item I can equally just get it and it returns the right type.
https://hastebin.com/share/gebuqupuxi.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.