/// <summary> /// Set the item on this slot /// </summary> /// <param name="item"></param> public void setDisplayedItem(Item item, int barSlotIndex, int barSlotCount) { if (item != null) { gameObject.SetActive(true); icon = item == null?ItemIconController.Make(null, transform) : ItemIconController.Make( item, transform, true, true, barSlotIndex, (barSlotIndex, 0), World.Entities.Creatures.Player.InventoryTypes.HotBar ); } this.barSlotIndex = barSlotIndex; this.barSlotCount = barSlotCount; updateLocation(); }
/// <summary> /// Change the icon to a new item or no item /// </summary> /// <param name="newItem"></param> void changeIcon(Item newItem = null) { float currentAlpha = icon.currentOpacity; Destroy(icon.gameObject); icon = newItem == null ? ItemIconController.Make(null, transform) : ItemIconController.Make( newItem, transform, true, true, barSlotIndex, (barSlotIndex, 0), Player.InventoryTypes.HotBar ); if (isSelected) { markSelected(); } updateOpacity(currentAlpha); }