Okay. What I’m trying to do is create an array of prefabs, but I’m having trouble properly creating them and placing them in the array. I’ve tried several things so far, but these two actually compile and don’t crash immediately:
// 1. An array of GameObjects
public GameObject[] Weapons;
// Setting array size
Weapons = new GameObject[(int)WeaponBase.WeaponType.NumTypes];
Weapons[0] = GameObject.Find("MachineGun");
// 2. An array of base-class scripts
public WeaponBase[] Weapons;
// Setting array size
Weapons = new WeaponBase[(int)WeaponBase.WeaponType.NumTypes];
Weapons[0] = gameObject.AddComponent<WeaponBase>();
Neither of these options assigns the values from the prefab’s Inspector upon creation, but the objects do get created, and are assigned the values within their ctor. I used to be able to Instantiate this prefab before I implemented the array, but since that’s not working, nothing else is.
Any help would be appreciated. Thanks!