Consider an Inventory System
My Player has four inventories with four different inventory types (say a, b, c and d).
A, b, c and d are custom classes (variable containers) which all contain a name, sprite and description along with a few other variables that are specific to each class.
I have an Inventory Display GameObject that I wish to be able to display all classes’ name, sprite and description. How might I do this? If you see a flaw in my logic or a potentially better solution, I am all ears.
The code I am basically looking for:
public class Example : Monobehaviour {
public [interchangeable variable] [] varList;
public Image[] imageList;
int i = 0;
foreach ([interchangeable variable] var in varList) {
imageList[i].sprite = var.sprite;
i++;
}
}
All help is appreciated