# Web View UGUI

## 🕸️ WebViewUGUI Class

A UI element with panning and zooming capabilities for viewing a skill web, supporting skill node interaction and visualization.

> Namespace: `Esper.SkillWeb.UI.UGUI`\
> Inherits from: `RuntimeWebViewer`, implements: `IScrollHandler`, `IBeginDragHandler`, `IDragHandler`

***

### 📦 Fields

| Access          | Field                 | Type                                     | Description                                                                                                        |
| --------------- | --------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `public`        | `enableTesting`       | `bool`                                   | Enables test mode (grants skill points on load).                                                                   |
| `public`        | `startingSkillPoints` | `int`                                    | Skill points used when testing is enabled.                                                                         |
| `public`        | `content`             | `RectTransform`                          | Root container of the view.                                                                                        |
| `public`        | `graphContent`        | `RectTransform`                          | UI that is panned and zoomed.                                                                                      |
| `public`        | `bounds`              | `RectTransform`                          | Bounds of the skill web.                                                                                           |
| `public`        | `clampInsideScreen`   | bool                                     | If true, automatic bounds will use the screen size as the bounds. Otherwise, the size of the content will be used. |
| `public`        | `loadedSkillNodes`    | `Dictionary<int, SkillNodeUGUI>`         | Skill node instances currently in the view.                                                                        |
| `public`        | `loadedConnections`   | `Dictionary<Connection, ConnectionUGUI>` | Active connection instances.                                                                                       |
| `public`        | `targetScale`         | `Vector3`                                | Target zoom level. *(NonSerialized)*                                                                               |
| `public`        | `targetPosition`      | `Vector2`                                | Target panning position. *(NonSerialized)*                                                                         |
| `public`        | `move`                | `Vector2`                                | Constant movement vector. *(NonSerialized)*                                                                        |
| `public`        | `zoomDelta`           | `float`                                  | Constant zoom strength. *(NonSerialized)*                                                                          |
| `public`        | `IsOpen`              | `bool`                                   | Whether the view is currently visible.                                                                             |
| `public static` | `Active`              | `WebViewUGUI`                            | The currently active instance.                                                                                     |
| `public static` | `Instance`            | `WebViewUGUI`                            | (Obsolete) Use `Active` instead.                                                                                   |

***

### 🧾 Properties

| Access          | Property   | Type          | Description                            |
| --------------- | ---------- | ------------- | -------------------------------------- |
| `public`        | `IsOpen`   | `bool`        | Returns true if the content is active. |
| `public static` | `Active`   | `WebViewUGUI` | Gets the current active view.          |
| `public static` | `Instance` | `WebViewUGUI` | (Obsolete) Use `Active` instead.       |

***

### 🧰 Methods

| Access           | Method                                                                                  | Returns       | Description                                       |
| ---------------- | --------------------------------------------------------------------------------------- | ------------- | ------------------------------------------------- |
| `public static`  | `Find(string webName, bool log = true)`                                                 | `WebViewUGUI` | Finds a view with a specific web name.            |
| `public`         | `SetActive()`                                                                           | `void`        | Sets this view as active and syncs the selector.  |
| `public virtual` | `Open()`                                                                                | `void`        | Shows the web view.                               |
| `public virtual` | `Close()`                                                                               | `void`        | Hides the web view.                               |
| `public virtual` | `Toggle()`                                                                              | `void`        | Toggles open/close state.                         |
| `public`         | `Unload()`                                                                              | `void`        | Clears all UI and resets scale/position.          |
| `public`         | `Load(WebGraph webGraph)`                                                               | `void`        | Loads a web from a graph definition.              |
| `public`         | `Load(Web web)`                                                                         | `void`        | Loads a web directly.                             |
| `public`         | `Load()`                                                                                | `void`        | Loads current assigned web.                       |
| `public`         | `ResetAllSkills()`                                                                      | `void`        | Resets all skills in the web.                     |
| `public`         | `CreateVisualConnectionLine(Vector2 position, int nodeID, int prefabIndex = 0)`         | `void`        | Creates a dummy connection to a node.             |
| `public`         | `CreateVisualConnectionLine(Vector2 position, SkillNodeUGUI node, int prefabIndex = 0)` | `void`        | Creates a dummy connection to a node.             |
| `public`         | `Focus(SkillNodeUGUI node)`                                                             | `void`        | Focuses the camera on a specific skill node.      |
| `public`         | `RemoveFocus()`                                                                         | `void`        | Clears current focus from selector.               |
| `public`         | `ResetView()`                                                                           | `void`        | Resets the graph to starting scale and position.  |
| `public`         | `Move(Vector2 dir)`                                                                     | `void`        | Pans the graph in a direction.                    |
| `public`         | `Snap(SkillNodeUGUI node)`                                                              | `void`        | Instantly snaps to the given node.                |
| `public`         | `UpgradeFocused()`                                                                      | `void`        | Attempts to upgrade the currently focused node.   |
| `public`         | `DowngradeFocused()`                                                                    | `void`        | Attempts to downgrade the currently focused node. |
| `public`         | `Focus(Vector2 dir)`                                                                    | `void`        | Focuses the next closest node in a direction.     |
| `public`         | `SetConstantZoom(float zoomStrength)`                                                   | `void`        | Applies continuous zoom.                          |
| `public`         | `Zoom(Vector2 position, float scrollDelta, bool normalize = true)`                      | `void`        | Zooms the graph towards a screen position.        |
| `public`         | `OnScroll(PointerEventData eventData)`                                                  | `void`        | Handles scroll-based zooming.                     |
| `public`         | `OnBeginDrag(PointerEventData eventData)`                                               | `void`        | Starts panning.                                   |
| `public`         | `OnDrag(PointerEventData eventData)`                                                    | `void`        | Updat                                             |
