# Shop Item Element UGUI

## 🛒 ShopItemElementUGUI Class

An element that represents a shop item.

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

***

### 📦 Fields

| Access   | Field             | Type              | Description                                |
| -------- | ----------------- | ----------------- | ------------------------------------------ |
| `public` | `button`          | `Button`          | Click target.                              |
| `public` | `itemIcon`        | `Image`           | Item icon image.                           |
| `public` | `itemBackground`  | `Image`           | Item background image.                     |
| `public` | `costIcon`        | `Image`           | Currency icon for cost.                    |
| `public` | `dimensionsLabel` | `TextMeshProUGUI` | Displays item dimensions.                  |
| `public` | `nameLabel`       | `TextMeshProUGUI` | Item name label.                           |
| `public` | `itemTypeLabel`   | `TextMeshProUGUI` | Item type label.                           |
| `public` | `costLabel`       | `TextMeshProUGUI` | Cost text label.                           |
| `public` | `shopkeeper`      | `Shopkeeper`      | Assigned shopkeeper (hidden in inspector). |
| `public` | `item`            | `Item`            | Assigned item (hidden in inspector).       |

***

### 🧰 Methods

| Access              | Method                                          | Returns       | Description                                                        |
| ------------------- | ----------------------------------------------- | ------------- | ------------------------------------------------------------------ |
| `private`           | `Awake()`                                       | `void`        | Subscribes to `costLabel` pre‑render to trigger resize.            |
| `private`           | `OnPreRenderText(TMP_TextInfo obj)`             | `void`        | Starts small coroutine to adjust label rect.                       |
| `private`           | `Resize()`                                      | `IEnumerator` | Adjusts `costLabel` rect after layout pass.                        |
| `public`            | `SetShopItem(Shopkeeper shopkeeper, Item item)` | `void`        | Assigns references, wires hover/click handlers, calls `Refresh()`. |
| `protected virtual` | `OnPointerEnter()`                              | `void`        | Opens hover details.                                               |
| `protected virtual` | `OnPointerExit()`                               | `void`        | Closes hover details.                                              |
| `protected virtual` | `OnClick()`                                     | `void`        | Invokes click event and calls `BuyItem()`.                         |
| `protected`         | `BuyItem()`                                     | `void`        | Performs buy flow (instant, confirm, or quantity selection).       |
| `public`            | `Refresh()`                                     | `void`        | Updates visuals and localized labels from `item`.                  |
