//creats slots for this bag public void AddSlots(int slotCount) { for (int i = 0; i < slotCount; i++) { SlotScript slot = Instantiate(slotPrefab, transform).GetComponent <SlotScript>(); slot.MyBag = this; MySlots.Add(slot); } }
/// <summary> /// Creates Slots for this bag /// </summary> /// <param name="slotCount">Amount of slots to create</param> public void AddSlots(int slotCount) { for (int i = 0; i < slotCount; i++) { // create a slot cannled slot and set reference to its script SlotScript slot = Instantiate(slotPrefab, transform).GetComponent <SlotScript>(); // make sure the bag knows what bag it belongs to slot.MyBag = this; // add this slot to the list of slots MySlots.Add(slot); } }