# Item Slot Element UGUI

## 🎴 ItemSlotElementUGUI Class

An any‑purpose item slot element for uGUI.

> **Namespace:** `Esper.Inventool.UI.UGUI`\
> **Access:** `public`\
> **Type:** `class`\
> **Inherits:** `DraggableElementUGUI`

***

### 📦 Fields

| Access                | Field                     | Type                       | Description                                                  |
| --------------------- | ------------------------- | -------------------------- | ------------------------------------------------------------ |
| `public`              | `acceptedItemType`        | `ItemType`                 | The item type the slot will accept; null accepts any.        |
| `public` *(Obsolete)* | `acceptedEnchantmentMode` | `ItemType.EnchantmentMode` | Obsolete: use `canAccept` custom filter instead.             |
| `public`              | `canAccept`               | `Func<ItemStack, bool>`    | Filter that allows/disallows items; defaults to `x => true`. |
| `public`              | `rectTransform`           | `RectTransform`            | The RectTransform for this element.                          |
| `public`              | `button`                  | `Button`                   | The button component.                                        |
| `public`              | `slotIcon`                | `Image`                    | Image that displays the slot icon.                           |
| `public`              | `itemIcon`                | `Image`                    | Image that displays the item icon.                           |
| `public`              | `itemBackground`          | `Image`                    | Image that displays the item background.                     |
| `public`              | `amountLabel`             | `TextMeshProUGUI`          | Label that displays the stack amount.                        |
| `public`              | `onItemUpdated`           | `UnityEvent`               | Invoked when an item is placed or removed.                   |
| `public`              | `actionMenuOptions`       | `List<ActionMenuOption>`   | Action menu options for this slot.                           |
| `protected`           | `dragElement`             | `ItemSlotElementUGUI`      | The temporary drag visual created while dragging.            |
| `public`              | `itemStack`               | `ItemStack`                | The item stack currently in this slot.                       |
| `public`              | `useItemRestrictions`     | `bool`                     | If true, `canAccept` and `acceptedItemType` are enforced.    |
| `public`              | `showAmount`              | `bool`                     | If true, stack amount text is shown.                         |

***

### 🔍 Properties

| Access   | Property  | Type   | Description                                     |
| -------- | --------- | ------ | ----------------------------------------------- |
| `public` | `HasItem` | `bool` | True if `itemStack` and its `item` are present. |

***

### 🧰 Methods

| Access              | Method                         | Returns | Description                                                                                                               |
| ------------------- | ------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------- |
| `private`           | `Awake()`                      | `void`  | Initializes drag behavior, hover handlers, click handler, and default action menu (Remove).                               |
| `protected virtual` | `OnPointerEnter()`             | `void`  | Invokes slot hover event and opens hover details for this slot.                                                           |
| `protected virtual` | `OnPointerExit()`              | `void`  | Closes hover details.                                                                                                     |
| `protected virtual` | `OnClick()`                    | `void`  | Invokes slot clicked event, opens action menu, and clears UI selection.                                                   |
| `public virtual`    | `SetItem(ItemStack itemStack)` | `bool`  | Sets the slot item if allowed; updates amount label, invokes `onItemUpdated`, refreshes visuals; returns true on success. |
| `public virtual`    | `RemoveItem()`                 | `void`  | Removes the current item, clears amount label, invokes `onItemUpdated`, refreshes visuals.                                |
| `protected`         | `DragStartedHandler()`         | `void`  | Creates and registers a drag visual in ItemDragAreaUGUI.                                                                  |
| `protected virtual` | `DragHandler()`                | `void`  | Moves the drag visual to follow the mouse, accounting for canvas render mode.                                             |
| `protected virtual` | `DropHandler()`                | `void`  | Removes drag visual, closes hover details if necessary.                                                                   |
| `protected virtual` | `OpenActionMenu()`             | `void`  | Opens the InventoolActionMenuUGUI with this slot's `actionMenuOptions` if it has an item.                                 |
| `public virtual`    | `Refresh()`                    | `void`  | Updates icon/background/amount visuals based on `itemStack`; reopens hover details if currently targeted.                 |

***
