# Equipment Window UGUI

## 🎒 EquipmentWindowUGUI Class

Inventool’s equipment window for uGUI.

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

***

### 📦 Fields

| Access          | Field                    | Type                             | Description                                    |
| --------------- | ------------------------ | -------------------------------- | ---------------------------------------------- |
| `protected`     | `equipmentTitle`         | `TextMeshProUGUI`                | The equipment title element.                   |
| `protected`     | `slotContainer`          | `GameObject`                     | Container that holds all equipment slots.      |
| `protected`     | `closeButton`            | `Button`                         | The close button.                              |
| `protected`     | `rotationResetButton`    | `Button`                         | Button to reset the character viewer rotation. |
| `protected`     | `rows`                   | `GameObject[]`                   | All row GameObjects in the equipment layout.   |
| `protected`     | `equipmentSlotElements`  | `List<EquipmentSlotElementUGUI>` | All equipment slot elements.                   |
| `protected`     | `characterViewerElement` | `CharacterViewerElementUGUI`     | The character viewer element.                  |
| `public`        | `characterViewer`        | `CharacterViewer`                | The active character viewer.                   |
| `public static` | `Instance`               | `EquipmentWindowUGUI`            | The active instance.                           |

***

### 🧰 Methods

| Access               | Method                                                                     | Returns                    | Description                                                                 |
| -------------------- | -------------------------------------------------------------------------- | -------------------------- | --------------------------------------------------------------------------- |
| `protected override` | `Awake()`                                                                  | `void`                     | Initializes singleton, wires buttons, collects slot elements, localizes UI. |
| `protected override` | `Start()`                                                                  | `void`                     | Sets character viewer, configures slots visibility, starts refresh routine. |
| `protected virtual`  | `HandleItemEquipped(ItemStack itemStack, EquipmentSlot equipmentSlot)`     | `void`                     | Refreshes slots and marks item as equipped in inventory UI.                 |
| `protected virtual`  | `HandleItemUnequipped(ItemStack itemStack, , EquipmentSlot equipmentSlot)` | `void`                     | Refreshes slots and clears equipped indicator in inventory UI.              |
| `public`             | `LocalizeElements()`                                                       | `void`                     | Localizes window UI elements.                                               |
| `public`             | `SetCharacterViewer(Sprite sprite)`                                        | `void`                     | Sets viewer to a static sprite (or enables 3D view if null).                |
| `public`             | `SetCharacterViewer()`                                                     | `void`                     | Sets viewer to the scene `CharacterViewer` (3D rotated render).             |
| `public virtual`     | `ResetCharacterViewRotation()`                                             | `void`                     | Resets the character view rotation and stops dragging.                      |
| `public`             | `RefreshAllEquipmentSlots()`                                               | `void`                     | Refreshes all equipment slot visuals and data binding.                      |
| `private`            | `RefreshAllEquipmentSlotsCoroutine()`                                      | `IEnumerator`              | Enables rows/slots by parity, then refreshes all equipment slots.           |
| `public`             | `GetEquipmentSlotElementAtPoint(Vector2 point)`                            | `EquipmentSlotElementUGUI` | Gets the slot element at a screen point or null.                            |
| `public virtual`     | `Toggle()`                                                                 | `void`                     | Toggles the window open/close state.                                        |
| `public override`    | `Open()`                                                                   | `void`                     | Opens the window, sets active, and invokes `onOpened`.                      |

## Active Instance

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

## Opening & Closing

### Open

Call the `Open` method when the player wants to open their equipment.

```csharp
EquipmentWindowUGUI.Instance.Open();
```

### Close

`Close` simply closes the window.

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

### Toggle

Optionally, you can use `Toggle` to open or close the window.

```csharp
EquipmentWindowUGUI.Instance.Toggle();
```
