Hi everyone,
I have a question that keeps bothering me.
I have a script on a player called Inventory. This script contains an array for Weapons. During run time I want to add a new weapon to this array.
//inventory script
public Weapon[] inventory;
void Start()
{
inventory = new Weapon[3];
inventory[0] = new Gun1();
However, the weapon has all kinds of public attributes that I want to fill in via the editor. For instance, every weapon has an attribute for an weapon icon. I want an artist to fill in these attributes via the editor. But then I need to attach the script to an object in order to fill in these attributes.
//Gun1 script
public Texture2D weaponIcon;
What is a good approach to assign an icon to, for instance, a prefab with the gun script on it and then adding this prefab to the array? So that the array can acces the prefabs gun icon?
I hope the question is clear. thanks in advance for your answer.