# Inventool Hover Details UGUI

## 📜 InventoolHoverDetailsUGUI Class

A mini pop-up window that displays item details.

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

***

### 📦 Fields

| Access      | Field                        | Type                    | Description                                             |
| ----------- | ---------------------------- | ----------------------- | ------------------------------------------------------- |
| `protected` | `statElementPrefab`          | `StatElementUGUI`       | The stat element prefab.                                |
| `protected` | `content`                    | `RectTransform`         | The content container.                                  |
| `protected` | `canvas`                     | `Canvas`                | The canvas component.                                   |
| `protected` | `animator`                   | `Animator`              | The animator component.                                 |
| `protected` | `itemBackground`             | `Image`                 | Image used to display the item background.              |
| `protected` | `itemIcon`                   | `Image`                 | Image used to display the item icon.                    |
| `protected` | `itemNameLabel`              | `TextMeshProUGUI`       | Label that displays the item name.                      |
| `protected` | `itemTypeLabel`              | `TextMeshProUGUI`       | Label that displays the item type.                      |
| `protected` | `descriptionScroll`          | `ScrollRect`            | Scroll rect that contains the description.              |
| `protected` | `descriptionLabel`           | `TextMeshProUGUI`       | Label that displays the description.                    |
| `protected` | `statsScroll`                | `ScrollRect`            | Scroll rect that displays all stats.                    |
| `protected` | `weightArea`                 | `GameObject`            | Object that contains weight content.                    |
| `protected` | `weightLabel`                | `TextMeshProUGUI`       | Label that displays the item's weight.                  |
| `protected` | `currencyIcon`               | `Image`                 | Image that displays the currency icon.                  |
| `protected` | `currencyLabel`              | `TextMeshProUGUI`       | Label that displays the currency amount.                |
| `protected` | `bottomArea`                 | `RectTransform`         | Element that contains the bottom content.               |
| `protected` | `separator`                  | `RectTransform`         | The separator element.                                  |
| `protected` | `lvlArea`                    | `RectTransform`         | Parent element of the level objects.                    |
| `protected` | `lvlLabel`                   | `TextMeshProUGUI`       | Label that displays the current item level.             |
| `protected` | `expSlider`                  | `Slider`                | Level progress bar display.                             |
| `protected` | `expProgressLabel`           | `TextMeshProUGUI`       | Level progress text.                                    |
| `protected` | `durabilityArea`             | `RectTransform`         | Parent element of the durability objects.               |
| `protected` | `durabilityLabel`            | `TextMeshProUGUI`       | Label that displays the durability text.                |
| `protected` | `durabilitySlider`           | `Slider`                | Durability progress bar display.                        |
| `protected` | `durabilityProgressLabel`    | `TextMeshProUGUI`       | Durability progress text.                               |
| `protected` | `loadedStatElements`         | `List<StatElementUGUI>` | A list of loaded stat elements.                         |
| `public`    | `appearanceDelay`            | `float`                 | Time the user must hover before details appear.         |
| `protected` | `autoScrollDelay`            | `float`                 | Delay when auto-scroll reaches the start or end.        |
| `protected` | `descriptionAutoScrollSpeed` | `float`                 | Auto-scroll speed for the description scroll rect.      |
| `protected` | `statsAutoScrollSpeed`       | `float`                 | Auto-scroll speed for the stats scroll rect.            |
| `protected` | `autoScrollDescriptionToEnd` | `bool`                  | If the description auto-scroll is currently to the end. |
| `protected` | `autoScrollStatsToEnd`       | `bool`                  | If the stats auto-scroll is currently to the end.       |
| `protected` | `openAction`                 | `Action`                | The open action queued during transitions.              |
| `protected` | `transitionState`            | `TransitionState`       | The current transition state.                           |

***

### 🔍 Properties

| Access   | Property   | Type                        | Description                                  |
| -------- | ---------- | --------------------------- | -------------------------------------------- |
| `public` | `Target`   | `RectTransform`             | The RectTransform currently being targeted.  |
| `public` | `IsOpen`   | `bool`                      | True if the hover details is currently open. |
| `public` | `Instance` | `InventoolHoverDetailsUGUI` | The active instance.                         |

***

### 🧰 Methods

| Access      | Method                                   | Returns       | Description                                                                |
| ----------- | ---------------------------------------- | ------------- | -------------------------------------------------------------------------- |
| `protected` | `Awake()`                                | `void`        | Initializes singleton, sets canvas, resets state, hides content.           |
| `public`    | `SetElements(ItemStack itemStack)`       | `void`        | Populates UI for an item stack (icons, text, stats, level, durability).    |
| `public`    | `SetElements(Item item)`                 | `void`        | Populates UI for an item (icons, text, stats, level, durability).          |
| `protected` | `OpenWithDelay()`                        | `IEnumerator` | Waits for `appearanceDelay` then opens near Target.                        |
| `public`    | `Open(ItemStackElementUGUI target)`      | `void`        | Queues opening for an inventory item stack element after delay.            |
| `public`    | `Open(EquipmentSlotElementUGUI target)`  | `void`        | Queues opening for an equipment slot element if it has an item.            |
| `public`    | `Open(ItemSlotElementUGUI target)`       | `void`        | Queues opening for a general item slot element if it has an item.          |
| `public`    | `Open(ShopItemElementUGUI target)`       | `void`        | Queues opening for a shop item element.                                    |
| `public`    | `Open(RectTransform target)`             | `void`        | Opens the window, starts auto-scrolls, positions relative to target/mouse. |
| `protected` | `Resize()`                               | `void`        | Resizes the window based on dynamic content and screen height.             |
| `protected` | `ForceInsideView()`                      | `IEnumerator` | Positions the window and clamps it inside the viewport.                    |
| `public`    | `IsTargetted(RectTransform target)`      | `bool`        | True if the given RectTransform is currently targeted.                     |
| `public`    | `Close()`                                | `void`        | Plays closing animation and stops coroutines; queues next open if any.     |
| `public`    | `Opened()`                               | `void`        | Sets transition state to Opened (animation callback helper).               |
| `public`    | `Closed()`                               | `void`        | Sets transition state to Closed, hides content, executes queued open.      |
| `protected` | `DescriptionAutoScrollLoopedCoroutine()` | `IEnumerator` | Auto-scrolls description up and down in a loop with delays.                |
| `protected` | `StatsAutoScrollLoopedCoroutine()`       | `IEnumerator` | Auto-scrolls stats up and down in a loop with delays.                      |

***

### 🧩 Nested Types

#### `protected enum TransitionState`

| Name      | Description                 |
| --------- | --------------------------- |
| `Opened`  | The window is fully open.   |
| `Opening` | The window is opening.      |
| `Closed`  | The window is fully closed. |
| `Closing` | The window is closing.      |

## Active Instance

You can get the active `InventoolHoverDetailsUGUI` instance with `InventoolHoverDetailsUGUI.Instance`. Ensure there's an instance of it in your scene before using this field.

## Open

Opening the hover details essentially requires a `RectTransform` target. By default, Inventool has special UI elements that hold a reference to an item, which is used by the `InventoolHoverDetailsUGUI` class to both open at the location of the UI element and also display the item details. So, it's not as easy as just calling an `Open` method.

```csharp
// This may only open the hover details without setting the item
InventoolHoverDetailsUGUI.Instance.Open(myVisualElement);
```

## Close

```csharp
InventoolHoverDetailsUGUI.Instance.Close();
```
