/// <summary> /// Sets the equipped items. /// </summary> /// <param name="unit">Unit.</param> public void SetEquippedItems(Unit unit) { _inventorySlots = unit.GetInventorySlots(); // Delete existing slot image (if exists) before adding new one. // TODO: Clearly, this is terrible. Come up with better solution. ClearAllSlotImages(); ClearAttributeText(); // Iterate over weapons/armor and add foreach (Item item in _inventorySlots.GetInventorySlots().Values) { SetAllAttributesText(item); GameObject slotPanel = GetPanelBySlot(item.SlotType).transform.Find("Slot").gameObject; RectTransform rectTransform = (RectTransform)slotPanel.transform; float height = rectTransform.rect.height; float width = rectTransform.rect.width; // Create slot images SlotImageCanvas.InstantiateInstance( slotImageCanvasPrefab, item, slotPanel, toolTipPanel, toolTipPanelSecondary, width, height ); } }