public void OnEnable() { td_target = (TopDownItem)target; if (TopDownIcon == null) { TopDownIcon = Resources.Load("TopDownIcon") as Texture; } }
/// <summary> /// Adds specified item to first free inventory slot. /// </summary> /// <param name="item"></param> public void AddItem(TopDownItem item) { if (items.Count >= itemSpace) { Debug.Log("No more room in the inventory."); } else { for (int i = 0; i < slots.Length; i++) { if (slots[i].itemInSlot == null) { items.Add(item.item); slots[i].AddItemToSlot(item.item); Destroy(item.gameObject); return; } } } }